diff --git a/repro_resharding_write_before_temp_ns_refresh.js b/repro_resharding_write_before_temp_ns_refresh.js
|
new file mode 100644
|
index 0000000000..7012fae165
|
--- /dev/null
|
+++ b/repro_resharding_write_before_temp_ns_refresh.js
|
@@ -0,0 +1,33 @@
|
+(function() {
|
+"use strict";
|
+
|
+load("jstests/sharding/libs/resharding_test_fixture.js");
|
+
|
+const reshardingTest = new ReshardingTest({numDonors: 2, numRecipients: 2, reshardInPlace: true});
|
+reshardingTest.setup();
|
+
|
+const donorShardNames = reshardingTest.donorShardNames;
|
+const sourceCollection = reshardingTest.createShardedCollection({
|
+ ns: "reshardingDb.coll",
|
+ shardKeyPattern: {oldKey: 1},
|
+ chunks: [
|
+ {min: {oldKey: MinKey}, max: {oldKey: 10}, shard: donorShardNames[0]},
|
+ {min: {oldKey: 10}, max: {oldKey: MaxKey}, shard: donorShardNames[1]},
|
+ ],
|
+});
|
+
|
+const recipientShardNames = reshardingTest.recipientShardNames;
|
+reshardingTest.withReshardingInBackground( //
|
+ {
|
+ newShardKeyPattern: {newKey: 1},
|
+ newChunks: [
|
+ {min: {newKey: MinKey}, max: {newKey: 10}, shard: recipientShardNames[0]},
|
+ {min: {newKey: 10}, max: {newKey: MaxKey}, shard: recipientShardNames[1]},
|
+ ],
|
+ },
|
+ () => {
|
+ assert.commandWorked(sourceCollection.insert({_id: 0, oldKey: 5, newKey: 15}));
|
+ });
|
+
|
+reshardingTest.teardown();
|
+})();
|
diff --git a/src/mongo/db/s/resharding/resharding_donor_service.cpp b/src/mongo/db/s/resharding/resharding_donor_service.cpp
|
index 2a7200f38e..6ba5aa0973 100644
|
--- a/src/mongo/db/s/resharding/resharding_donor_service.cpp
|
+++ b/src/mongo/db/s/resharding/resharding_donor_service.cpp
|
@@ -263,6 +263,8 @@ void ReshardingDonorService::DonorStateMachine::
|
->assertNoIndexBuildInProgForCollection(_donorDoc.getExistingUUID());
|
}
|
|
+ sleepsecs(10);
|
+
|
// Recipient shards expect to read from the donor shard's existing sharded collection
|
// and the config.cache.chunks collection of the temporary resharding collection using
|
// {atClusterTime: <fetchTimestamp>}. Refreshing the temporary resharding collection on
|