Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6947

db.createCollection creates undefined fields which cause mongorestore to fail

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.5, 2.4.4, 2.5.0
    • Affects Version/s: 2.2.0, 2.3.1
    • Component/s: Admin, Tools
    • Environment:
      Ubuntu 12.04 64bit using 10gen repositories
    • ALL
    • Hide

      > use test
      > db.dropDatabase()
      > db.createCollection("coll")

      $ mongodump

      > db.coll.drop()

      $ mongorestore

      Show
      > use test > db.dropDatabase() > db.createCollection("coll") $ mongodump > db.coll.drop() $ mongorestore

      The db.createCollection() helper has some optional collection options which get set to undefined if they are not provided. This causes mongodump to output undefined elements which can cause mongorestore to fail.

      The documents have the form:

      { "options" : { "create" : "coll", "capped" :

      { "$undefined" : true }

      , "size" :

      { "$undefined" : true }

      }, "indexes" : [ { "v" : 1, "key" :

      { "_id" : 1 }

      , "ns" : "test.coll", "name" : "id" } ] }

        1. after_fix.txt
          3 kB
        2. before_fix.txt
          3 kB
        3. create_restore_test
          1 kB

            Votes:
            7 Vote for this issue
            Watchers:
            22 Start watching this issue

              Created:
              Updated:
              Resolved: