[SERVER-8312] return value "n" in db.getLastErrorCmd() have BUG Created: 24/Jan/13 Updated: 11/Jul/16 Resolved: 18/Feb/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying, Write Ops |
| Affects Version/s: | 2.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | HongYing | Assignee: | Ian Daniel |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
FreeBSD 7.3-RELEASE FreeBSD 7.3-RELEASE root@:/usr/src/sys/amd64/compile/GENERIC amd64 |
||
| Operating System: | FreeBSD |
| Steps To Reproduce: | > db.bobo.save( {a:1, b:2, c:3, d:4}) > db.bobo.update( {a:1, b:2}, {$unset:{c:1, d:1}}) , ) { "_id" : ObjectId("5100b05af1c2c68819360d1a"), "a" : 1, "b" : 2 }> db.bobo.update( {a:1}, {$unset:{b:1}}) , |
| Participants: |
| Description |
|
After updating and unsetting a field, we get result by db.getLastErrorCmd(). |
| Comments |
| Comment by Ian Daniel [ 04/Feb/13 ] | |
|
Hi HongYing, It looks like you might be running these commands interactively in the shell. db.getLastError() is unreliable in the shell. A carriage return in the shell results in GetLastError being run. This then produced unreliable results when you call it again. There are several possible solutions: 1. Write up your commands into a file with a .js suffix, and pass it to mongo at the command line. 2. If running interactively, put the db.getLastErrorCmd() on the same line as the update (separated by a semi-colon). That is:
3. If you want to run it on a separate line, instead use the db.getPrevError() command. 4. Set verbose to true in the shell (set verbose true). This will then tell you how many objects were updated. If none of these actually fixes the problem, are you sharding? I ask because in the just released 2.2.3 we fixed several bugs in which a mongos returns an incorrect GetLastError. You should try in 2.2.3 to see if this resolves the problem. Kind regards, |