Uploaded image for project: 'MongoDB CLI Tools'
  1. MongoDB CLI Tools
  2. TOOLS-936

Add option to force mongorestore to build indexes in the background

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Accepted
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: mongorestore
    • Labels:
    • Case:
    • Documentation Changes:
      Needed
    • Documentation Changes Summary:
      Hide
      previously indexes were always built in the foreground. Now in 3.6 indexes will be build in the background by default, and if one wants for indexes to be built in the foreground, they'll need to provide the --allowForegroundIndexBuild on the command line.
      Show
      previously indexes were always built in the foreground. Now in 3.6 indexes will be build in the background by default, and if one wants for indexes to be built in the foreground, they'll need to provide the --allowForegroundIndexBuild on the command line.

      Description

      mongorestore currently restores indexes with their original options as recorded by mongodump. If an index was originally created with background:true it will be built in the background, but the default behaviour is to build indexes in the foreground which is a blocking operation. When restoring data into a production environment, foreground index builds can cause unexpected outages.

      A default behaviour with less surprise would be to force all indexes to be built in the background regardless of the original background value. A parameter like --allowForegroundIndexBuilds could be added to speed up the builds if the user is aware of the caveats.

      Two limited workarounds I've seen used:

      • update the *.metadata.json files in the dump directory to add background:true if not present
      • use mongorestore's --noIndexRestore option to avoid accidentally building any indexes in the foreground, and then create the indexes with background:true after mongorestore finishes restoring the data. This requires knowledge of the indexes & options that need to be recreated, which may again be found by parsing mongodump's *.metadata.json files if there is no easier source available.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                backlog-server-tools Backlog - Server Tools Team
                Reporter:
                stennie Stennie Steneker
              • Votes:
                26 Vote for this issue
                Watchers:
                25 Start watching this issue

                Dates

                • Created:
                  Updated: