-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.2.0, 2.3.0
-
Component/s: Write Ops
-
None
-
Environment:storm 0.8
-
ALL
using strom, the threads(also in different process) run code:
myDB("mytable").update(DBObject("key1" -> new ObjectId(myKey), "key2" -> coKey), myUpdates, true, false, WriteConcern.SAFE)
and my storm log as following (node1 and node2 is different machine, the last two columns is using :System.currentTimeMillis(),Thread.currentThread() ):
on node1: storm-0.8.1/logs/worker-6711.log:2012-09-14 11:18:11 STDIO [INFO] 1347592691476 Thread[Thread-16,5,main] on node2: storm-0.8.1/logs/worker-6705.log:2012-09-14 11:18:11 STDIO [INFO] 1347592691456 Thread[Thread-24,5,main]
there is no record in mytable meets the query
DBObject("key1" -> new ObjectId(myKey), "key2" -> coKey)
before they run, and after they run, there will exist exactly two same records, which I think is quite the opposite of what I know of the meaning of upsert = true.
from the logs:
Fri Sep 21 13:18:57 [initandlisten] MongoDB starting : pid=32671 port=27017 dbpath=/home/myuser/mydb 64-bit host=mymachine Fri Sep 21 13:18:57 [initandlisten] db version v2.2.0, pdfile version 4.5 .... Fri Sep 21 13:35:29 [conn196] update mydb.mytable query: { key1: "k12306", key2: "k86" } update: { field1: "f1", field2: "f2" } nscanned:3341 nupdated:1 upsert:1 keyUpdates:0 numYields: 26 locks(micros) w:7033 333ms ... Fri Sep 21 13:35:29 [conn192] update mydb.mytable query: { key1: "k12306", key2: "k86" } update: { field1: "f1", field2: "f2" } nscanned:3343 nupdated:1 upsert:1 keyUpdates:0 numYields: 26 locks(micros) w:6906 335ms ....
we can see that the commands which cause duplicated records is shown above.
other conditions is:
a) when mytable is with index on db.mytable.ensureIndex(
), it works ok, no duplicated record generated.
b) when mytable is without any index, which will cause every mongo command cost much longer time, bang~, the duplicated records appeared..
original thread:
https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/MBafvLXkTYw
- is duplicated by
-
SERVER-9423 Make findAndModify/update + upsert == atomic
- Closed
- is related to
-
SERVER-4639 update yielding with upsert can duplicate a document
- Closed