[SERVER-5346] document field (key) magically changed by mongodb Created: 21/Mar/12  Updated: 07/Mar/14  Resolved: 21/Mar/12

Status: Closed
Project: Core Server
Component/s: Stability, Storage, Usability, Write Ops
Affects Version/s: 1.8.1, 1.8.2, 1.8.3, 2.0.1, 2.0.2, 2.0.3, 2.0.4
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Stone, Gao Assignee: Aaron Staple
Resolution: Duplicate Votes: 0
Labels: bug,, magical-mongodb,
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

linux


Issue Links:
Duplicate
duplicates SERVER-4776 improper application of modifiers wit... Closed
Operating System: Linux
Participants:

 Description   

Please refer to the following code:

// on mongodb 1.8.x

use test_db
db.revs.save({})
doc = db.revs.findOne()
db.revs.update(

{ _id : doc._id }

, { $inc :

{ "versions.2_01" : 1 }

} )

db.revs.findOne()
{
"_id" : ObjectId("4f699826d603f81fdec82a62"),
"versions" :

{ "2_01" : 1 }

}

db.revs.update(

{ _id : doc._id }

, { $inc :

{ "versions.2_1" : 1 }

} )

db.revs.findOne()
{
"_id" : ObjectId("4f699826d603f81fdec82a62"),
"versions" :

{ "2_1" : 2 // key magically changed to 2_1 !!! }

}

db.revs.update(

{ _id : doc._id }

, { $inc :

{ "versions.2_01" : 1 , "01" : 1 }

} )
db.revs.findOne()
{
"_id" : ObjectId("4f699826d603f81fdec82a62"),
"versions" :

{ "2_01" : 3 }

,
"01" : 1
}

db.revs.update(

{ _id : doc._id }

, { $inc :

{ "versions.2_01" : 1 , "1" : 1 }

} )
db.revs.findOne()
{
"_id" : ObjectId("4f699826d603f81fdec82a62"),
"versions" :

{ "2_01" : 4 // key magically changed back to 2_01 !!! }

,
"1" : 2 // key magically changed to 1 !!!
}

//==========================================================

// on mongodb 2.0.x

use test_db
db.revs.save({})
doc = db.revs.findOne()
db.revs.update(

{ _id : doc._id }

, { $inc :

{ "versions.2_01" : 1 }

} )

db.revs.findOne()
{
"_id" : ObjectId("4f69a044e5ce33194e694fdc"),
"versions" :

{ "2_01" : 1 }

}

db.revs.update(

{ _id : doc._id }

, { $inc :

{ "versions.2_1" : 1 }

} )

db.revs.findOne()
{
"_id" : ObjectId("4f69a044e5ce33194e694fdc"),
"versions" :

{ "2_1" : 1, "2_01" : 1 // nice, seems that this kind of bug fixed in 2.0.x }

}

db.revs.update(

{ _id : doc._id }

, { $inc :

{ "versions.2_01" : 1 , "01" : 1 }

} )
db.revs.findOne()
{
"_id" : ObjectId("4f69a044e5ce33194e694fdc"),
"versions" :

{ "2_1" : 1, "2_01" : 2 }

,
"01" : 1
}

db.revs.update(

{ _id : doc._id }

, { $inc :

{ "versions.2_01" : 1 , "1" : 1 }

} )
db.revs.findOne()
{
"_id" : ObjectId("4f69a044e5ce33194e694fdc"),
"versions" :

{ "2_1" : 1, "2_01" : 3 // nice, seems that this kind of bug (*_0x) fixed in 2.0.x }

,
"1" : 2 // key magically changed to 01 agin in 2.0.x, this kind of bug (0x) still not fully fixed !!!
}



 Comments   
Comment by Eliot Horowitz (Inactive) [ 21/Mar/12 ]

This was fixed in SERVER-4776
Will see if that can get backported

Comment by Eliot Horowitz (Inactive) [ 21/Mar/12 ]

This is fixed in head currently (for 2.2)

We can see which case resolved this so we can determine if we can backport to 2.0

Comment by auto [ 21/Mar/12 ]

Author:

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

Message: explicit test for SERVER-5346
Branch: master
https://github.com/mongodb/mongo/commit/3ca90a1f7a6069ad5325e2543147d1215e339dc0

Generated at Thu Feb 08 03:08:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.