[SERVER-1777] Assertion error in findAndModify Created: 11/Sep/10  Updated: 14/Sep/18  Resolved: 23/Sep/10

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 1.6.2
Fix Version/s: 1.7.1

Type: Bug Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux 64


Operating System: ALL
Participants:

 Description   

On empty DB, I'm trying to ensure that I insert exactly one record like this:

{ short_code: 1 }

... and that concurrent processes doing the same thing will instead increment the short_code.

> db.runCommand({findAndModify: 'short_code', upsert: true, update: { $inc:

{ short_code: 1 }

}, query:

{ short_code: true }

, new: true })
{
"errmsg" : "exception: assertion db/../util/../util/../db/../bson/bsonobjbuilder.h:115",
"code" : 0,
"ok" : 0
}



 Comments   
Comment by Mathias Stearn [ 23/Sep/10 ]

The issue was that you were seeding with short_code:true and you can't $inc a boolean value in mongo. Of course the error was being swallowed in the command so you never saw it. Now it will return an error.

Comment by auto [ 23/Sep/10 ]

Author:

{'login': 'RedBeard0531', 'name': 'Mathias Stearn', 'email': 'mathias@10gen.com'}

Message: Pass through update error messages in findAndModify SERVER-1777
http://github.com/mongodb/mongo/commit/5c2e25e81c161c8f3b0f5b0df585fb62ac197a5b

Generated at Thu Feb 08 02:58:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.