[SERVER-1060] multi-update only affects Created: 28/Apr/10  Updated: 12/Jul/16  Resolved: 28/Apr/10

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 1.4.0, 1.4.1, 1.4.2, 1.5.0
Fix Version/s: 1.4.3, 1.5.1

Type: Bug Priority: Major - P3
Reporter: Daniel Cowgill Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MacOSX 64-bit, Ubuntu Karmic


Participants:

 Description   

Multi update doesn't affect all matching documents. As far as I can tell, the bug only occurs when the query is able to use an index.

This mongo shell transcript demonstrates the problem:

> db.foo.drop();
true
> db.foo.ensureIndex(

{k:1}

)
> for (i=0; i<10; i++) { db.foo.save(

{k: 'x', a: []}

); }
> db.foo.find();

{ "_id" : ObjectId("4bd85f77ad41955b0dcda4b7"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4b8"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4b9"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4ba"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4bb"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4bc"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4bd"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4be"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4bf"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4c0"), "k" : "x", "a" : [ ] }

> db.foo.update(

{k: 'x'}

, {$push: {a: 'y'}}, false, true);
> db.foo.find();

{ "_id" : ObjectId("4bd85f77ad41955b0dcda4b8"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4ba"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4bc"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4be"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4c0"), "k" : "x", "a" : [ ] } { "_id" : ObjectId("4bd85f77ad41955b0dcda4b7"), "a" : [ "y" ], "k" : "x" } { "_id" : ObjectId("4bd85f77ad41955b0dcda4b9"), "a" : [ "y" ], "k" : "x" } { "_id" : ObjectId("4bd85f77ad41955b0dcda4bb"), "a" : [ "y" ], "k" : "x" } { "_id" : ObjectId("4bd85f77ad41955b0dcda4bd"), "a" : [ "y" ], "k" : "x" } { "_id" : ObjectId("4bd85f77ad41955b0dcda4bf"), "a" : [ "y" ], "k" : "x" }

>

If I omit the ensureIndex call, all of the documents are updated correctly.

Tested in 1.2.2, 1.4.0, 1.4.2, and the most recent nightly dev build (v1.5.1-pre).



 Comments   
Comment by auto [ 03/May/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: more aggressive about checking for index moves in multi-update SERVER-1060
http://github.com/mongodb/mongo/commit/e9ef03782ca0b5f8d979a9c439d49c6ab8b540ce

Comment by auto [ 28/Apr/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: more aggressive about checking for index moves in multi-update SERVER-1060
http://github.com/mongodb/mongo/commit/4002e942bd96c55be54fda788eb680e8938a8533

Generated at Thu Feb 08 02:55:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.