Question about WriteResult

119 views
Skip to first unread message

smigfu

unread,
Dec 15, 2011, 11:29:13 AM12/15/11
to mongodb-user
Hi,

Could somebody help me understand the below last error message? This
result is from an update of an object (which has been written to Mongo
shortly before). We are using MongoDB 1.8.3 and Java driver 2.7.2

1. Insert object into shard (successfully)
2. Update object by _id (WriteResult writeResult =
dbCollection.update(query, update, false, false, WriteConcern.SAFE);)
query looks like: {_id : XYZ}
update looks like: {$set : {foo : bar, foo2 : bar2}}


Question #1: Result shows "updatedExisting" : true but "n" : 0.
Shouldn't updatedExisting be false if n is 0? At least when I try
locally against a non-shared Mongo it behaves like this. From what I
can tell the update has been successful.

Question #2: What do the writebackGLE and initialGLEHost properties
mean? Why do they mention a different ReplSet?

Question #3: Is there any way to see what "lastOp":5686019109100191745
really has been doing on the backend?

Thanks in advance :-)

- Philipp


{
writeResult = {
"serverUsed":"127.0.0.1:27017/myDB",
"singleShard":"ReplSet3/ec2-xxxx.compute-1.amazonaws.com:
27018,ec2-xxxx.compute-1.amazonaws.com:27018,ec2-
xxxx.compute-1.amazonaws.com:27018",
"n":0,
"lastOp":5686019109100191745,
"connectionId":1524,
"err":null,
"ok":1.0,
"updatedExisting":true,
"wtime":0,
"writebackGLE": {
"singleShard":"ReplSet3/ec2-xxxx.compute-1.amazonaws.com:
27018,ec2-xxxx.compute-1.amazonaws.com:27018,ec2-
xxxx.compute-1.amazonaws.com:27018",
"n":0,
"lastOp":5686019109100191745,
"connectionId":1524,
"err":null,
"ok":1.0
},
"initialGLEHost":"ReplSet1/ec2-xxxx.compute-1.amazonaws.com:
27018,ec2-xxxx.compute-1.amazonaws.com:27018,ec2-
xxxx.compute-1.amazonaws.com:27018"
}
}

Spencer T Brody

unread,
Dec 15, 2011, 6:12:50 PM12/15/11
to mongod...@googlegroups.com
1: Hmm, that's strange.  I haven't been able to reproduce that result.  Could be a bug - could you open a SERVER ticket in jira at jira.mongodb.org?

2: Seeing those fields means that the document being updated was mid-migration when the update occurred.  initialGLEHost is the shard the document *was* on, writebackGLE is the results of the getLastError command run on the shard that received the chunk at the end of the migration.

3: The lastOp field actually is a timestamp of when the last operation on that instance occurred.  You can see the most recent write operations by looking in the oplog, but to see the most recent read operations you'll have to have the profiler turned on.

smigfu

unread,
Dec 20, 2011, 4:54:50 AM12/20/11
to mongodb-user
Thanks Spencer,

I have opened the following bug https://jira.mongodb.org/browse/SERVER-4532.

Might the migration problem be part of the problem?

Cheers
Philipp

Shi Shei

unread,
Nov 6, 2012, 12:27:07 PM11/6/12
to mongod...@googlegroups.com, smi...@googlemail.com
It happend again using v2.2.0, so I've reopend the JIRA task.
Reply all
Reply to author
Forward
0 new messages