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

"storageEngine" key in collection options dumped as array instead of map

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 3.0.2, 3.1.1
    • Affects Version/s: 3.0.0, 3.0.1
    • Component/s: None
    • None
    • Kernel Tools Iteration 3.1.1
    • Not Needed
    • v3.0

      if someone has the "storageEngine" key in their collection options, it will be returned from the driver as a bson.D instead of a bson.M, and mongodump will write the map out as

      [{Name:"...", Value:"..."}, ...] 

      instead of as a regular map.

      Root cause looks like this function, which returns a bson.D, whose values can be marshaled into JSON if the structure is one level deep, but is marshalled as an array if its greater than 1 level deep (like the storageEngine options):
      https://github.com/mongodb/mongo-tools/blob/d063f417dcbfdf1ae578fc269a50533f5b9ea2d3/common/db/namespaces.go#L117

      to repro:
      1. create a collection with additional storageEngine options, e.g.

      > db.createCollection("testcoll", {storageEngine:{wiredTiger:{"configString":"block_compressor=snappy"}}}
      

      2. then dump the database
      3. then restore it - will get error: "error running create command: 'storageEngine' has to be a document"

      Workaround:
      Run mongodump as usual, but before restoring, edit the .metadata.json file so that the json object for the storageEngine key matches the correct format, e.g.:

      {storageEngine:{wiredTiger:{"configString":"..."}}}
      

            Assignee:
            kyle.erf Kyle Erf
            Reporter:
            mikeo@mongodb.com Michael O'Brien
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: