-
Type: Bug
-
Resolution: Cannot Reproduce
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
-
ALL
In 2.6+ versions of the mongo shell, there is the following check in the insert(), update() and remove() methods on the collection object:
if ( this.getMongo().writeMode() != "legacy" ) { // use write commands else { // use legacy write op, followed by getLastError }
The problem is, with versions of the server prior to 2.6 this.getMongo().writeMode() returns "compatibility", NOT "legacy", so the 'else' block in the above code is never executed.
The impact is that the write concern passed in by the caller is not respected, since getLastError is not called.
A workaround is for the user is to make an explicit getLastError call (on the same line, if running an interactive shell):
e.g.
db.foo.remove({_id:1}); db.runCommand({getLastError:1, w:2})
The above code works with both 2.4 and 2.6+ versions of the server.