Positional operator on update: command accepted without error, but data not updated.

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.5.4
    • Affects Version/s: 1.4.4
    • Component/s: Write Ops
    • None
    • Environment:
      Linux
    • Linux
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      testupdate3 did not exist at the beginning of this test.

      > db.testupdate3.ensureIndex(

      {'y.a':1,'y.b':1}

      )
      > db.testupdate3.save({x:1,y:[

      {a:1,b:2}

      ,

      {a:3,b:4}

      ]})

      > db.testupdate3.update(

      {'y.a':3,'y.b':4}

      ,{$set:{'y.$.b':10}},false,true)
      can't append to array using string field name
      > db.testupdate3.update(

      {'y.a':3,'y.b':4,x:1}

      ,{$set:{'y.$.b':10}},false,true)
      > db.testupdate2.find(

      {'y.a':3,'y.b':10}

      )
      { "_id" : ObjectId("4c2f5c449a684ff16748c1cf"), "x" : 1, "y" : [

      { "a" : 1, "b" : 2 }

      ,

      { "a" : 3, "b" : 10 }

      ] }
      > db.testupdate3.update(

      {'y.a':3,'y.b':10,x:1}

      ,{$set:{'y.$.b':4}},false,true)
      > db.testupdate3.find()
      { "_id" : ObjectId("4c2f5d749a684ff16748c1d2"), "x" : 1, "y" : [

      { "a" : 1, "b" : 2 }

      ,

      { "a" : 3, "b" : 10 }

      ] }

      Notice that the update fails, as in issue SERVER-1040, if we don't also include an additional restriction x:1 in the search.

      As an additional twist, I haven't been able to make a test case for this, but in our test environment, the above sequence DID (essentially) update b back to 4 in the second update. While the data was visible if you queried on (essentially) x, if you tried to query on y.a and y.b, it did NOT find the changed records, nor did it find if it you queried on your previous values of y.

      Is an index perhaps getting corrupted?

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

              Created:
              Updated:
              Resolved: