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:
And, occasionally:
[conn<M>] queryModified: { _id: <id>, $atomic: true, f.o:
}
[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 })
- related to
-
SERVER-6913 update allows upsert to "modify" _id
- Closed