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

Add option to force mongorestore to build indexes in the background

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: mongorestore
    • Not Needed
    • 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.

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            stephen.steneker@mongodb.com Stennie Steneker (Inactive)
            Votes:
            29 Vote for this issue
            Watchers:
            28 Start watching this issue

              Created:
              Updated:
              Resolved: