[SERVER-1821] Cannot update a collection using $inc modifier using a geo $center query unless the fields already exist in the matched documents Created: 21/Sep/10  Updated: 12/Jul/16  Resolved: 22/Nov/10

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 1.6.2
Fix Version/s: 1.7.4

Type: Bug Priority: Major - P3
Reporter: Sam Murphy Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OSX 64bit, Snow Leopard, Macbook


Operating System: ALL
Participants:

 Description   

db.createCollection("points");
db.points.ensureIndex(

{ loc : "2d" }

)

for(var x = 0; x < 10; x = x + 1) {
for(var y = 0; y < 10; y = y + 1) {
db.points.insert(

{"loc": [x, y]}

);
}
}

// Run geo $inc
db.points.update({"loc" : {"$within" :

{"$center" : [[5,5], 2]}

}}, {'$inc' : { 'test' : 1}}, false, true);

/////////////////
// FAILS:
// 0x10006e90b 0x10007d47c 0x10015fc70 0x100161759 0x100269532 0x10026b319 0x1003a5822 0x1003b6d84 0x7fff884fa8b6 0x7fff884fa769
// 0 mongod 0x000000010006e90b _ZN5mongo12sayDbContextEPKc + 171
// 1 mongod 0x000000010007d47c _ZN5mongo8assertedEPKcS1_j + 284
// 2 mongod 0x000000010015fc70 _ZN5mongo14_updateObjectsEbPKcRKNS_7BSONObjES2_bbbRNS_7OpDebugEPNS_11RemoveSaverE + 6864
// 3 mongod 0x0000000100161759 _ZN5mongo13updateObjectsEPKcRKNS_7BSONObjES2_bbbRNS_7OpDebugE + 313
// 4 mongod 0x0000000100269532 _ZN5mongo14receivedUpdateERNS_7MessageERNS_5CurOpE + 1170
// 5 mongod 0x000000010026b319 _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_8SockAddrE + 5513
// 6 mongod 0x00000001003a5822 _ZN5mongo10connThreadEPNS_13MessagingPortE + 546
// 7 mongod 0x00000001003b6d84 thread_proxy + 132
// 8 libSystem.B.dylib 0x00007fff884fa8b6 _pthread_start + 331
// 9 libSystem.B.dylib 0x00007fff884fa769 thread_start + 13
// Mon Sep 20 19:08:35 [conn7] Caught Assertion in update , continuing

// Run a non-geo $inc
db.points.update({}, {'$inc' : { 'test' : 1}}, false, true);

// No error

// Re-run geo $inc
db.points.update({"loc" : {"$within" :

{"$center" : [[5,5], 2]}

}}, {'$inc' : { 'test' : 1}}, false, true);

// No error



 Comments   
Comment by Eliot Horowitz (Inactive) [ 09/Nov/10 ]

this is a bit trickier than expected.

almost have to make Geo*Cursor yield safe...

Comment by auto [ 27/Sep/10 ]

Author:

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

Message: test for SERVER-1821
http://github.com/mongodb/mongo/commit/5a5d766199cd952c868484d4c1e3fd880092c291

Comment by Sam Murphy [ 27/Sep/10 ]

It was my understanding from the documentation that an $inc will create fields if they do not exist. In the test file the "z" field is created prior to using an $inc. I believe that removing that will create an error.

Is is expected that the fields being incremented have to exist in advance?

Comment by Eliot Horowitz (Inactive) [ 24/Sep/10 ]

Added a test that does exactly this that seems to work fine.
Can you try running and see what happens?
mongo jstests/geo_update1.js

Comment by auto [ 24/Sep/10 ]

Author:

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

Message: test for SERVER-1821
http://github.com/mongodb/mongo/commit/f8da5e06860a0d5e0fd7b5637fcc748127cfbcc3

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