Closed (fixed)
Project:
MongoDB
Version:
7.x-1.x-dev
Component:
Queue
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
8 May 2012 at 21:54 UTC
Updated:
25 May 2012 at 14:30 UTC
In queue module fina and modify comamnd is used to get the next item and lock it. In 1.8 version of Mongo they changed what "ok" parameter in response does. Even if it doesn't find an entry it will return ok:1 and value:null which can cause errors queue processing.
Ran simple test on 2.0.4
> db.foo.find()
{ "_id" : ObjectId("4fa99312a53f69a8c09ac9f5"), "a" : 1, "b" : 2 }
{ "_id" : ObjectId("4fa99316a53f69a8c09ac9f6"), "a" : 2, "b" : 2 }
> db.runCommand({findAndModify: "foo", query: {a:1}, update:{$set:{b:3}}})
{
"lastErrorObject" : {
"updatedExisting" : true,
"n" : 1,
"connectionId" : 1,
"err" : null,
"ok" : 1
},
"value" : {
"_id" : ObjectId("4fa99312a53f69a8c09ac9f5"),
"a" : 1,
"b" : 2
},
"ok" : 1
}
> db.foo.find()
{ "_id" : ObjectId("4fa99312a53f69a8c09ac9f5"), "a" : 1, "b" : 3 }
{ "_id" : ObjectId("4fa99316a53f69a8c09ac9f6"), "a" : 2, "b" : 2 }
> db.runCommand({findAndModify: "foo", query: {a:3}, update:{$set:{b:3}}})
{ "value" : null, "ok" : 1 }
You can see that last command even though it doesn't change any documents still responds with ok:1. Attached patch checks that value is set and should work on older versions as well.
| Comment | File | Size | Author |
|---|---|---|---|
| mongo-queue-findandmodify.patch | 636 bytes | Rok Žlender |
Comments
Comment #1
marcingy commentedComment #2
misc commentedThanks.
Committed to the latest dev.