summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Fuschetto <antonio.fuschetto@mongodb.com>2022-01-07 09:39:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-07 10:02:33 +0000
commit1a99f108fe8ef92ac35b66e22e92fa316193504a (patch)
tree1755b6ae899c04389b3ad87fce39057bf5afef66
parent86773e0404ac646ad94e510852c0274bb9257b42 (diff)
downloadmongo-1a99f108fe8ef92ac35b66e22e92fa316193504a.tar.gz
SERVER-61969 Simplify exact_shard_key_target.js so that it does not depend on orphan writing
-rw-r--r--jstests/sharding/exact_shard_key_target.js27
1 files changed, 4 insertions, 23 deletions
diff --git a/jstests/sharding/exact_shard_key_target.js b/jstests/sharding/exact_shard_key_target.js
index 4182b06b9e1..e2c4dc25b0f 100644
--- a/jstests/sharding/exact_shard_key_target.js
+++ b/jstests/sharding/exact_shard_key_target.js
@@ -28,39 +28,20 @@ st.printShardingStatus();
coll.remove({});
assert.commandWorked(coll.insert({_id: 1, a: {b: -1}}));
assert.commandWorked(coll.insert({_id: 2, a: {b: 1}}));
-// Need orphaned data to see the impact
-assert.commandWorked(st.shard0.getCollection(coll.toString()).insert({_id: 3, a: {b: 1}}));
-assert.eq(1, coll.remove({a: {b: 1}}, {justOne: true}).nRemoved);
-assert.eq(2,
- st.shard0.getCollection(coll.toString()).count() +
- st.shard1.getCollection(coll.toString()).count());
+var explainOutput = coll.explain().remove({a: {b: 1}}, {justOne: true});
+assert.eq(1, explainOutput.queryPlanner.winningPlan.shards.length);
//
// Non-multi update
coll.remove({});
-// When the 'featureFlagNoChangeStreamEventsDueToOrphans' is enabled, orphaned documents are not
-// actually removed by the 'remove' command to avoid unexpected events on change streams. In this
-// scenario, it is necessary to remove them explicitly from the shards that own them.
-const clusterParams = assert.commandWorked(st.configRS.getPrimary().adminCommand(
- {getParameter: 1, featureFlagNoChangeStreamEventsDueToOrphans: 1}));
-if (clusterParams.featureFlagNoChangeStreamEventsDueToOrphans.value) {
- assert.commandWorked(st.shard0.getCollection(coll.toString()).remove({_id: 3}));
-}
assert.commandWorked(coll.insert({_id: 1, a: {b: 1}}));
assert.commandWorked(coll.insert({_id: 2, a: {b: -1}}));
-// Need orphaned data to see the impact
-assert.commandWorked(st.shard0.getCollection(coll.toString()).insert({_id: 3, a: {b: 1}}));
-assert.eq(1, coll.update({a: {b: 1}}, {$set: {updated: true}}, {multi: false}).nMatched);
-assert.eq(1,
- st.shard0.getCollection(coll.toString()).count({updated: true}) +
- st.shard1.getCollection(coll.toString()).count({updated: true}));
+explainOutput = coll.explain().update({a: {b: 1}}, {$set: {updated: true}}, {multi: false});
+assert.eq(1, explainOutput.queryPlanner.winningPlan.shards.length);
//
// Successive upserts (replacement-style)
coll.remove({});
-if (clusterParams.featureFlagNoChangeStreamEventsDueToOrphans.value) {
- assert.commandWorked(st.shard0.getCollection(coll.toString()).remove({_id: 3}));
-}
assert.commandWorked(coll.update({a: {b: 1}}, {a: {b: 1}}, {upsert: true}));
assert.commandWorked(coll.update({a: {b: 1}}, {a: {b: 1}}, {upsert: true}));
assert.eq(1,