Description
When connecting with a 2.6.0-rc0 mongo shell to a 2.4.9 server and causing a duplicate key error due to a unique index, the insert or update is silently ignored and no error is printed. This is different behavior to both 2.4.9 shell with 2.4.9 server and 2.6.0 shell with 2.6.0 server.
Behavior with 2.4.9 shell and server:
MongoDB shell version: 2.4.9
|
connecting to: test
|
> db.serverStatus()['version']
|
2.4.9
|
> db.moo.update({a: 2}, {a: 1})
|
E11000 duplicate key error index: test.moo.$a_1 dup key: { : 1.0 }
|
Behavior with 2.6.0-rc0 shell and server:
MongoDB shell version: 2.6.0-rc0
|
connecting to: test
|
> db.serverStatus()['version']
|
2.6.0-rc0
|
> db.moo.update({a: 2}, {a: 1})
|
WriteResult({
|
"nMatched" : 0,
|
"nUpserted" : 0,
|
"nModified" : 0,
|
"writeError" : {
|
"code" : 11000,
|
"errmsg" : "E11000 duplicate key error index: test.moo.$a_1 dup key: { : 1.0 }"
|
}
|
})
|
Behavior with 2.6.0-rc0 shell, 2.4.9 server:
MongoDB shell version: 2.6.0-rc0
|
connecting to: test
|
> db.serverStatus()['version']
|
2.4.9
|
> db.moo.update({a: 2}, {a: 1})
|
> db.moo.update({a: 2}, {a: 1}); db.getLastError()
|
E11000 duplicate key error index: test.moo.$a_1 dup key: { : 1.0 }
|
The error only gets printed when calling db.getLastError() directly on the same line.
Attachments
Issue Links
- duplicates
-
SERVER-13015 2.6.0-rc0: Update that violates sparse index is not done, generates no complaint.
-
- Closed
-