Core Server
  1. Core Server
  2. SERVER-6993

findAndModify positional operator regression with undotted query fields

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major - P3 Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.2.1, 2.3.0
    • Component/s: Write Ops
    • Labels:
      None
    • Backport:
      Done
    • # Replies:
      7
    • Last comment by Customer:
      false

      Description

      We are in the works of upgrading our server to 2.2.0, however we hit an issue with this: https://jira.mongodb.org/browse/SERVER-6588. It appears that this has already been fixed on 2.2 rc1 and according to your roadmap it will be available on 9/25. Is this for the Production version or the Development version? If it's for Production release, when is the soonest we could get the Dev version?

      1. batch.json
        0.8 kB
        Jhoanna Ilagan
      2. mongo2.0.6.txt
        1 kB
        Jhoanna Ilagan
      3. mongo2.2.0.txt
        1 kB
        Jhoanna Ilagan

        Issue Links

          Activity

          Hide
          Dan Pasette
          added a comment -

          This was fixed in the production release of 2.2.0. "rc1" stands for "release candidate 1"

          Show
          Dan Pasette
          added a comment - This was fixed in the production release of 2.2.0. "rc1" stands for "release candidate 1"
          Hide
          Jhoanna Ilagan
          added a comment -

          We do have the Prod release of 2.2.0, and we seem to have the issue
          similar to (https://jira.mongodb.org/browse/SERVER-6588).

          Here's what we're doing:

          mongoimport -d Test -c Batch /data/logs/batch.json

          Update the job:

          db.Batch.findAndModify({query: { "_id":
          "4ddb4161-0324-4e5e-988f-b7f089f26afd", job: { $elemMatch:

          { "jobId": "1" }

          } }, update: { $set: { "job.$.endTime": new Date(1347060957254),
          "lastUpdate": new Date(1347060957254), "job.$.lastUpdate": new
          Date(1347060957254), "job.$.properties":

          { "rows": "113", "size": "20K" }

          ,
          "job.$.status": "completed" } }, new: true });

          In version 2.2.0 I am getting error message uncaught exception:
          findAndModifyFailed failed: {
          "errmsg" : "exception: can't append to array using string
          field name [$]",
          "code" : 13048,
          "ok" : 0

          Thanks,
          Jhoanna

          Show
          Jhoanna Ilagan
          added a comment - We do have the Prod release of 2.2.0, and we seem to have the issue similar to ( https://jira.mongodb.org/browse/SERVER-6588 ). Here's what we're doing: mongoimport -d Test -c Batch /data/logs/batch.json Update the job: db.Batch.findAndModify({query: { "_id": "4ddb4161-0324-4e5e-988f-b7f089f26afd", job: { $elemMatch: { "jobId": "1" } } }, update: { $set: { "job.$.endTime": new Date(1347060957254), "lastUpdate": new Date(1347060957254), "job.$.lastUpdate": new Date(1347060957254), "job.$.properties": { "rows": "113", "size": "20K" } , "job.$.status": "completed" } }, new: true }); In version 2.2.0 I am getting error message uncaught exception: findAndModifyFailed failed: { "errmsg" : "exception: can't append to array using string field name [$] ", "code" : 13048, "ok" : 0 Thanks, Jhoanna
          Hide
          David Hows
          added a comment -

          Hi Jhoanna,

          You dont need the elemMatch as only one sub element of the array is needed to be matched. ElemMatch is used when you need to match two or more elements of an array and ensure both are present in the same array element.

          I found removing the elemMatch worked as i believe you intended, that is the following query:

          db.Batch.findAndModify({query: { "_id":
          "4ddb4161-0324-4e5e-988f-b7f089f26afd", "job.jobId": "1"  }, update: { $set: { "job.$.endTime": new Date(1347060957254),
          "lastUpdate": new Date(1347060957254), "job.$.lastUpdate": new
          Date(1347060957254), "job.$.properties": { "rows": "113", "size": "20K" },
          "job.$.status": "completed" } }, new: true });
          

          Having said that, if an elemMatch is needed there is an issue. I will make a separate comment for this.

          Cheers,

          David

          Show
          David Hows
          added a comment - Hi Jhoanna, You dont need the elemMatch as only one sub element of the array is needed to be matched. ElemMatch is used when you need to match two or more elements of an array and ensure both are present in the same array element. I found removing the elemMatch worked as i believe you intended, that is the following query: db.Batch.findAndModify({query: { "_id": "4ddb4161-0324-4e5e-988f-b7f089f26afd", "job.jobId": "1" }, update: { $set: { "job.$.endTime": new Date(1347060957254), "lastUpdate": new Date(1347060957254), "job.$.lastUpdate": new Date(1347060957254), "job.$.properties": { "rows": "113", "size": "20K" }, "job.$.status": "completed" } }, new: true }); Having said that, if an elemMatch is needed there is an issue. I will make a separate comment for this. Cheers, David
          Hide
          David Hows
          added a comment -

          While Jhoanna's query did not need an elemMatch the following query - which would need an elemMatch and use of the positional operator fails with the error Jhoanna noted. I am using Jhoanna's dataset, but have added a second sub element (status) thus the need for elemMatch.

          Query:

          db.Batch.findAndModify({query: { "_id":
          "4ddb4161-0324-4e5e-988f-b7f089f26afd", job: { $elemMatch: { "jobId": "1", "status": "running" } } }, update: { $set: { "job.$.endTime": new Date(),
          "lastUpdate": new Date(), "job.$.lastUpdate": new
          Date(), "job.$.properties": { "rows": "113", "size": "20K" },
          "job.$.status": "completed" } }, new: true });

          Error:

          uncaught exception: findAndModifyFailed failed: {
            "errmsg": "exception: can't append to array using string field name [$]",
            "code": 13048,
            "ok": 0
          }
          

          This appears to be an issue in the modify alone - as running this query when no document can be found that matches will cause the findAndModify to return a null.

          Show
          David Hows
          added a comment - While Jhoanna's query did not need an elemMatch the following query - which would need an elemMatch and use of the positional operator fails with the error Jhoanna noted. I am using Jhoanna's dataset, but have added a second sub element (status) thus the need for elemMatch. Query: db.Batch.findAndModify({query: { "_id": "4ddb4161-0324-4e5e-988f-b7f089f26afd", job: { $elemMatch: { "jobId": "1", "status": "running" } } }, update: { $set: { "job.$.endTime": new Date(), "lastUpdate": new Date(), "job.$.lastUpdate": new Date(), "job.$.properties": { "rows": "113", "size": "20K" }, "job.$.status": "completed" } }, new: true }); Error: uncaught exception: findAndModifyFailed failed: { "errmsg": "exception: can't append to array using string field name [$]", "code": 13048, "ok": 0 } This appears to be an issue in the modify alone - as running this query when no document can be found that matches will cause the findAndModify to return a null.
          Hide
          Jhoanna Ilagan
          added a comment -

          Thanks for your help.

          This works for us. This ticket is resolved.

          Show
          Jhoanna Ilagan
          added a comment - Thanks for your help. This works for us. This ticket is resolved.
          Hide
          auto
          added a comment -

          Author:

          {u'date': u'2012-09-18T17:26:54-07:00', u'email': u'eliot@10gen.com', u'name': u'Eliot Horowitz'}

          Message: SERVER-6993 - fix findAndModify positional operator regression with undotted query fields
          Branch: master
          https://github.com/mongodb/mongo/commit/4cfe47b8c3c529df5cca132a007ad7d2d5b3ba29

          Show
          auto
          added a comment - Author: {u'date': u'2012-09-18T17:26:54-07:00', u'email': u'eliot@10gen.com', u'name': u'Eliot Horowitz'} Message: SERVER-6993 - fix findAndModify positional operator regression with undotted query fields Branch: master https://github.com/mongodb/mongo/commit/4cfe47b8c3c529df5cca132a007ad7d2d5b3ba29
          Hide
          auto
          added a comment -

          Author:

          {u'date': u'2012-09-18T17:26:54-07:00', u'email': u'eliot@10gen.com', u'name': u'Eliot Horowitz'}

          Message: SERVER-6993 - fix findAndModify positional operator regression with undotted query fields
          Branch: v2.2
          https://github.com/mongodb/mongo/commit/242597ae464698f8fc243ec869654cdc756dabb9

          Show
          auto
          added a comment - Author: {u'date': u'2012-09-18T17:26:54-07:00', u'email': u'eliot@10gen.com', u'name': u'Eliot Horowitz'} Message: SERVER-6993 - fix findAndModify positional operator regression with undotted query fields Branch: v2.2 https://github.com/mongodb/mongo/commit/242597ae464698f8fc243ec869654cdc756dabb9

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                1 year, 31 weeks ago
                Date of 1st Reply: