Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1060

multi-update only affects

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.3, 1.5.1
    • Affects Version/s: 1.4.0, 1.4.1, 1.4.2, 1.5.0
    • Component/s: Write Ops
    • None
    • Environment:
      MacOSX 64-bit, Ubuntu Karmic

      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).

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            dcowgill Daniel Cowgill
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: