[SERVER-6909] verify assertion when new version of a document is requested that does not match dotted field expression of original query; excessive logging Created: 31/Aug/12  Updated: 11/Jul/16  Resolved: 18/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: Critical - P2
Reporter: Aristarkh Zagorodnikov Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File mdb.log.gz    
Issue Links:
Depends
Related
related to SERVER-6913 update allows upsert to "modify" _id Closed
Operating System: Linux
Participants:

 Description   

The update version of findAndModify attempts to find the new version of a document using a modified version of the original query (queryModified). A dotted field expression may be copied from the original query to queryModified, but if that field is changed by the update the constraint on that field may cause the match to fail and prevent the new version of the document from being found. (And this causes the verify to fire.)

Test

c = db.c;
c.drop();
 
c.save( { a:{ b:1 } } );
c.findAndModify( { query:{ 'a.b':1 },
                   update:{ $set:{ 'a.b':2 } }, // Ensure the query on 'a.b' no longer matches.          
                   new:true } );

It also looks like there is a debugging log line in the code:

log() << "queryModified: " << queryModified << endl;

– Aaron

-----------------------------------------------

My logs are filled with the following:
[conn<X>] queryModified:

{ _id: <any id> }

And, occasionally:
[conn<M>] queryModified: { _id: <id>, $atomic: true, f.o:

{ $exists: false }

}
[conn<N>] <collection> Assertion failure Helpers::findOne( ns.c_str() , queryModified , doc ) src/mongo/db/commands/find_and_modify.cpp 184

The resulting error is: exception: assertion src/mongo/db/commands/find_and_modify.cpp:184 (response:

{ "errmsg" : "exception: assertion src/mongo/db/commands/find_and_modify.cpp:184", "code" : 0, "ok" : 0.0 }

)



 Comments   
Comment by auto [ 18/Sep/12 ]

Author:

{u'date': u'2012-09-17T23:08:03-07:00', u'email': u'eliot@10gen.com', u'name': u'Eliot Horowitz'}

Message: SERVER-6909 fix case where update can modify document such that query doesn't work anymore
Branch: v2.2
https://github.com/mongodb/mongo/commit/414a7dc114f34a341c8b4907a4e24760b449e724

Comment by auto [ 18/Sep/12 ]

Author:

{u'date': u'2012-09-17T23:08:03-07:00', u'email': u'eliot@10gen.com', u'name': u'Eliot Horowitz'}

Message: SERVER-6909 fix case where update can modify document such that query doesn't work anymore
Branch: master
https://github.com/mongodb/mongo/commit/e398691aec2a351426366cf3bc1e10cfcd05ea16

Comment by Aristarkh Zagorodnikov [ 08/Sep/12 ]

Backport sounds great, because we like everything about 2.2.

Comment by Ian Whalen (Inactive) [ 08/Sep/12 ]

onyxmaster - keep an eye on this ticket as there's a chance it will also be backported to a 2.2.x release (pending review by our team)

Comment by Aristarkh Zagorodnikov [ 08/Sep/12 ]

Well, looks like we're sticking with 2.0 until 2.4 comes.

Comment by Ian Whalen (Inactive) [ 07/Sep/12 ]

onyxmaster, we haven't solidified what's in/out yet, but the plan is indeed to fix for the 2.4.0 stable release.

Comment by Sergey Shinderuk [ 07/Sep/12 ]

One more test case (without a dotted expression):

> db.c.remove()
> db.c.findAndModify({ query: {_id: 1, x: 0}, update: { $set:

{x: 1}

}, new: true, upsert: true })
Fri Sep 7 13:19:18 uncaught exception: findAndModifyFailed failed: {
"errmsg" : "exception: assertion src/mongo/db/commands/find_and_modify.cpp:184",
"code" : 0,
"ok" : 0
}

Comment by Aristarkh Zagorodnikov [ 01/Sep/12 ]

Thanks for the information.
Is this still considered a bug, so we should wait for 2.4 (Fix Version/s 2.3.x imply that), or an [undocumented] breaking change, so we should either rewrite our applications or stick with 2.0 forever?

Comment by Aristarkh Zagorodnikov [ 31/Aug/12 ]

The entire contents of one of our master 2.2 upgrade attempt.

Comment by Scott Hernandez (Inactive) [ 31/Aug/12 ]

Please attach a large section of your log.

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