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.

CommentFileSizeAuthor
mongo-queue-findandmodify.patch636 bytesRok Žlender
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcingy’s picture

Status: Needs review » Reviewed & tested by the community
MiSc’s picture

Status: Reviewed & tested by the community » Fixed

Thanks.
Committed to the latest dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.