[SERVER-3217] $push and $pushAll oplog is not idempotent Created: 08/Jun/11 Updated: 28/Sep/12 Resolved: 28/Sep/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 1.8.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Alexey Guseynov | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Operating System: | ALL | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
Run following commands on replica set: replica:PRIMARY> db.foo.insert( {"_id":"test", x:[1, 2, 3]}) , {$pushAll: {x:[4]}}) , {$pull: {x:1}}) ) { "_id" : "test", "x" : [ 2, 3, 4 ] }View oplog: { "ts" : { "t" : 1307521384000, "i" : 1 }, "h" : NumberLong("-2482281928928604340"), "op" : "i", "ns" : "points.foo", "o" : { "_id" : "test", "x" : [ 1, 2, 3 ] } } , "h" : NumberLong("9215593517142594101"), "op" : "u", "ns" : "points.foo", "o2" : { "_id" : "test", "x" : { "$size" : 3 }}, "o" : { "$pushAll" : { "x" : [ 4 ] } } } , "h" : NumberLong("-4865163357721582816"), "op" : "u", "ns" : "points.foo", "o2" : { "_id" : "test" }, "o" : { "$pull" : { "x" : 1 }} } Now let's reexecute last two commands from oplog. They must be idempotent so after execution database content must not change: replica:PRIMARY> db.foo.update({ "_id" : "test", "x" : { "$size" : 3 }}, { "$pushAll" : { "x" : [ 4 ] } }) , { "$pull" : { "x" : 1 } }) ) { "_id" : "test", "x" : [ 2, 3, 4, 4 ] }But it changes. Because $pushAll was not rewritten in idempotent way. If you change $pushAll with $push the same example would work. Corresponding oplog message is: { "ts" : { "t" : 1307521870000, "i" : 1 }, "h" : NumberLong("-6895072222265747191"), "op" : "u", "ns" : "points.foo", "o2" : { "_id" : "test2", "x" : { "$size" : 3 }}, "o" : { "$push" : { "x" : 4 }} } again mongo tests only array size. |
| Comments |
| Comment by Daniel Pasette (Inactive) [ 28/Sep/12 ] |
|
see |