Mongos allows a replacement-style single-update with an empty query but an update containing the shard key to be executed on the shards.
If the first document the update encountered by mongod contains the shard key, the update will be executed successfully.
Otherwise, the mongod will return the following write error to mongos, which is passed to the client:
[js_test:test] 2016-02-29T11:52:11.314-0500 assert: write failed with error: { [js_test:test] 2016-02-29T11:52:11.314-0500 "nMatched" : 0, [js_test:test] 2016-02-29T11:52:11.314-0500 "nUpserted" : 0, [js_test:test] 2016-02-29T11:52:11.315-0500 "nModified" : 0, [js_test:test] 2016-02-29T11:52:11.315-0500 "writeError" : { [js_test:test] 2016-02-29T11:52:11.315-0500 "code" : 66, [js_test:test] 2016-02-29T11:52:11.315-0500 "errmsg" : "After applying the update to the document {x: 5.0 , ...}, the (immutable) field 'x' was found to have been altered to x: 0.0" [js_test:test] 2016-02-29T11:52:11.315-0500 } [js_test:test] 2016-02-29T11:52:11.315-0500 } [js_test:test] 2016-02-29T11:52:11.315-0500 _getErrorWithCode@src/mongo/shell/utils.js:23:13 [js_test:test] 2016-02-29T11:52:11.315-0500 doassert@src/mongo/shell/assert.js:13:14 [js_test:test] 2016-02-29T11:52:11.315-0500 assert.writeOK@src/mongo/shell/assert.js:388:9 [js_test:test] 2016-02-29T11:52:11.315-0500 @test.js:31:1
Therefore, the behavior of the update on a mongos depends on the order of documents seen by the mongod.
- related to
-
SERVER-15551 Add a mongod mode to simulate sharded cluster constraints
- Backlog