-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: Legacy C++ Implementation
-
Component/s: mongoimport
-
None
-
Environment:Linux 2.6.35-23-generic #37-Ubuntu SMP Fri Nov 5 19:16:29 UTC 2010 x86_64 GNU/Linux
I found strange behavior. I found "duplicate record" errors from mongoimport are printed to the output correctly when I use --dbpath , but if I connect to the database via mongo daemon then I don't see those errors. Is it possible to have get those errors in same way as it appears with --dbpath . Actually, I think behavior should be the same for both ways, no matter how mongoimport connects to mongodb.
saulius@saulius:~/temp/mong$ cat data.csv
attribute1, attribute2
a,a
a,a
b,b
saulius@saulius:~/temp/mong$ mongod --version
db version v1.6.4, pdfile version 4.5
Wed Nov 3 19:06:55 git version:
4f5c02f8d92ff213b71b88f5eb643b7f62b50abc
saulius@saulius:~/temp/mong$ mongo
MongoDB shell version: 1.6.4
connecting to: test
> use things;
switched to db things
> db.things.remove();
> db.things.ensureIndex(
,
{unique: true});
> exit
bye
saulius@saulius:~/temp/mong$ sudo mongoimport --file data.csv --db
things --collection things --type csv --headerline
connected to: 127.0.0.1
imported 4 objects
No errors!!! Importer just silently skipped duplicate records:
saulius@saulius:~/temp/mong$ mongo
MongoDB shell version: 1.6.4
connecting to: test
> use things;
switched to db things
> db.things.find();
BUT, when I use direct import to mongodb files:
saulius@saulius:~/temp/mong$ mongoimport --file data.csv --db things
--collection things --type csv --headerline -dbpath /var/lib/mongodb/
Wed Nov 3 19:14:26 [tools] insert things.things exception 11000
E11000 duplicate key error index: things.things.
$attribute1_1_attribute2_1 dup key: { : "a", : "a" } 0ms
imported 4 objects
Wed Nov 3 19:14:26 dbexit:
Wed Nov 3 19:14:26 [tools] shutdown: going to close listening
sockets...
Wed Nov 3 19:14:26 [tools] shutdown: going to flush oplog...
Wed Nov 3 19:14:26 [tools] shutdown: going to close sockets...
Wed Nov 3 19:14:26 [tools] shutdown: waiting for fs preallocator...
Wed Nov 3 19:14:26 [tools] shutdown: closing all files...
Wed Nov 3 19:14:26 closeAllFiles() finished
Wed Nov 3 19:14:26 [tools] shutdown: removing fs lock...
Wed Nov 3 19:14:26 dbexit: really exiting now