[SERVER-1470] Update w/upsert ignores dbref field from query on insert Created: 22/Jul/10  Updated: 12/Jul/16  Resolved: 02/Jun/12

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 1.4.4, 1.5.5
Fix Version/s: 2.1.2

Type: Bug Priority: Critical - P2
Reporter: Scott Hernandez (Inactive) Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 6
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-3158 Inserting (as update with upset) DBRe... Closed
Operating System: ALL
Participants:

 Description   

> db.test.remove()
> db.test.update({ "name" : "first" , "pic" : { "$ref" : "Pic", "$id" : ObjectId("4c48d04cd33a5a92628c9af6") }}, {$set:{}}, true, true)
> db.test.find()

{ "_id" : ObjectId("4c48d2c9280e000000004377"), "name" : "first" }

The pic field is not saved; The actual update is more complicated but this is reduced to the minimum.

This was originally a problem from the 2.0 java driver but I doubt that has any bearing on the server.



 Comments   
Comment by auto [ 02/Jun/12 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-1470 fix upsert with dbref
Branch: master
https://github.com/mongodb/mongo/commit/f5fa68b120c00b0ccd9dbc95fe18502eb490feba

Comment by Joseph Monti [ 23/Jan/12 ]

This bug appears to be able to cause corruption of the shard chunk map when a DBRef is part of the shard key and an upsert is used. I think the mongos is routing the command to a particular shard based on the query doc in the update command, but this bug prevents all the query fields from being stored in the resulting document, so the resulting shard key may reside in a chunk that is supposed to be on another shard. Then when a chunk split happens, it may result in a bad chunk split and corrupt the chunk map. I think this is a similar problem for sharding as if you were to insert a document directly to a shard node rather than going through a mongos.

This mongodb-user group posting discusses this issue in a little more detail: https://groups.google.com/forum/#!topic/mongodb-user/yTVVIpFr1dY

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