[SERVER-6993] findAndModify positional operator regression with undotted query fields Created: 10/Sep/12  Updated: 11/Jul/16  Resolved: 19/Sep/12

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.2.0
Fix Version/s: 2.2.1, 2.3.0

Type: Bug Priority: Major - P3
Reporter: Jhoanna Ilagan Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File batch.json     Text File mongo2.0.6.txt     Text File mongo2.2.0.txt    
Issue Links:
Related
is related to SERVER-6588 findAndModify regression 2.0.x -> v2.... Closed
Participants:

 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?



 Comments   
Comment by auto [ 19/Sep/12 ]

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

Comment by auto [ 19/Sep/12 ]

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

Comment by Jhoanna Ilagan [ 11/Sep/12 ]

Thanks for your help.

This works for us. This ticket is resolved.

Comment by David Hows [ 11/Sep/12 ]

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.

Comment by David Hows [ 11/Sep/12 ]

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

Comment by Jhoanna Ilagan [ 10/Sep/12 ]

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

Comment by Daniel Pasette (Inactive) [ 10/Sep/12 ]

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

Generated at Thu Feb 08 03:13:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.