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

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

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

      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 Eliot Horowitz (Inactive)
            Reporter:
            dakarp Daniel Karp
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: