|
The problem appears to be that while $inc can utilize the implicit type conversion that SafeNum provides, $set does not work in an equivalent way and will not do implicit type conversion:
NumberLong $inc with NumberDouble -> NumberDouble
NumberLong $set to NumberDouble -> NumberLong (!!)
On the primary, it uses $inc to produce the result, but for idempotency, the secondary uses a $set to produce the same result.
One can see the problem with a simple test on a standalone node:
> db.a.insert({a1:NumberLong('-9223372036854775808')});
|
WriteResult({ "nInserted" : 1 })
|
> db.a.find()
|
{ "_id" : ObjectId("5669993a49e0557a277d9392"), "a1" : NumberLong("-9223372036854775808") }
|
> db.a.update({}, { $set: { a1: -9223372036854776000 } });
|
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })
|
> db.a.find()
|
{ "_id" : ObjectId("5669993a49e0557a277d9392"), "a1" : NumberLong("-9223372036854775808") }
|
|