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

mongoimport may report incorrect number of imported documents

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.11
    • Affects Version/s: None
    • Component/s: mongoimport
    • Not Needed

      The list of documents below contains a duplicate _id. mongoimport correctly flags this as an error, but claims the document was imported into the collection.

      $ cat export.js
      { "_id" : { "$oid" : "53c833593206b4df88d74ca7" }, "x" : "a" }
      { "_id" : { "$oid" : "53c833593206b4df88d74ca7" }, "x" : "b" }
      { "_id" : { "$oid" : "53c833593206b4df88d74ca8" }, "x" : "c" }
      { "_id" : { "$oid" : "53c833593206b4df88d74ca9" }, "x" : "d" }
      $ mongoimport --version
      mongoimport version: 2.7.8
      $ mongoimport --drop  -d test -c foo < export.js 
      2014-11-07T11:53:31.618-0500    connected to: localhost
      2014-11-07T11:53:31.618-0500    dropping: test.foo
      2014-11-07T11:53:31.621-0500    error inserting documents: insertDocument :: caused by :: 11000 E11000 duplicate key error index: test.foo.$_id_ dup key: { : ObjectId('53c833593206b4df88d74ca7') }
      2014-11-07T11:53:31.621-0500    imported 4 documents
      $ mongo --eval 'db.foo.count()'
      MongoDB shell version: 2.7.8
      connecting to: test
      3
      

        1. zips.json
          2.74 MB
          Nathan Leniz

            Assignee:
            david.golden@mongodb.com David Golden
            Reporter:
            ramon.fernandez@mongodb.com Ramon Fernandez Marina
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: