|
The latest stable release, MongoDB 3.2.1, does the right thing, both for WiredTiger and MMAPv1.
$ mlaunch init --single --port 11111 --binarypath /m/3.2.1/bin
|
launching: /m/3.2.1/bin/mongod on port 11111
|
$ /m/3.2.1/bin/mongo --port 11111 --norc
|
MongoDB shell version: 3.2.1
|
connecting to: 127.0.0.1:11111/test
|
> db.version()
|
3.2.1
|
> db.createCollection("foo", {capped: true, size: 10*1048576})
|
{ "ok" : 1 }
|
> db.foo.insert({_id:1})
|
WriteResult({ "nInserted" : 1 })
|
> db.foo.insert({_id:1})
|
WriteResult({
|
"nInserted" : 0,
|
"writeError" : {
|
"code" : 11000,
|
"errmsg" : "E11000 duplicate key error collection: test.foo index: _id_ dup key: { : 1.0 }"
|
}
|
})
|
> db.bar.insert({_id:1})
|
WriteResult({ "nInserted" : 1 })
|
> db.bar.insert({_id:1})
|
WriteResult({
|
"nInserted" : 0,
|
"writeError" : {
|
"code" : 11000,
|
"errmsg" : "E11000 duplicate key error collection: test.bar index: _id_ dup key: { : 1.0 }"
|
}
|
})
|
|