diff options
author | Randolph Tan <randolph@10gen.com> | 2019-02-11 14:09:50 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2019-02-14 12:28:12 -0500 |
commit | 055cc74476a7eedb7d51ccae06c46a9d25b80c5c (patch) | |
tree | c1ab9cb7c2c775bc8900816b4db425a1c618750b /jstests | |
parent | 8fac3580ab40811cbcb078ec9e1e2f16bfbf23a1 (diff) | |
download | mongo-055cc74476a7eedb7d51ccae06c46a9d25b80c5c.tar.gz |
SERVER-34733 mongos needs to also refresh db version after receiving onImplicitCreate error
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/unsharded_collection_targetting.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/jstests/sharding/unsharded_collection_targetting.js b/jstests/sharding/unsharded_collection_targetting.js new file mode 100644 index 00000000000..efe4c3c05c4 --- /dev/null +++ b/jstests/sharding/unsharded_collection_targetting.js @@ -0,0 +1,32 @@ +// Tests that a stale mongos would route writes correctly to the right shard after +// an unsharded collection was moved to another shard. +(function() { + "use strict"; + + const st = new ShardingTest({ + shards: 2, + mongos: 2, + rs: { + nodes: 1, + }, + }); + + const testName = 'test'; + const mongosDB = st.s0.getDB(testName); + + // Ensure that shard1 is the primary shard. + assert.commandWorked(mongosDB.adminCommand({enableSharding: mongosDB.getName()})); + st.ensurePrimaryShard(mongosDB.getName(), st.rs1.getURL()); + + // Before moving the collection, issue a write through mongos2 to make it aware + // about the location of the collection before the move. + const mongos2DB = st.s1.getDB(testName); + const mongos2Coll = mongos2DB[testName]; + assert.writeOK(mongos2Coll.insert({_id: 0, a: 0})); + + st.ensurePrimaryShard(mongosDB.getName(), st.rs0.getURL()); + + assert.writeOK(mongos2Coll.insert({_id: 1, a: 0})); + + st.stop(); +})(); |