[SERVER-13036] 2.6 shell silently ignores duplicate key error when connecting to 2.4 server Created: 04/Mar/14  Updated: 10/Dec/14  Resolved: 05/Mar/14

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.6.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Thomas Rueckstiess Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: gle
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-13015 2.6.0-rc0: Update that violates spars... Closed
Operating System: ALL
Participants:

 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.



 Comments   
Comment by Thomas Rueckstiess [ 04/Mar/14 ]

Looks like the problem has been fixed, the shell from master (git hash 33912523e40467e1a41bed60ed7e198200a040ad) now works as expected:

MongoDB shell version: 2.6.0-rc1-pre-
connecting to: test
> db.serverStatus()['version']
2.4.9
> db.moo.update({a: 2}, {a: 1})
Cannot use commands write mode, degrading to compatability mode
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 11001,
		"errmsg" : "E11000 duplicate key error index: test.moo.$a_1  dup key: { : 1.0 }"
	}
})

Generated at Thu Feb 08 03:30:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.