summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/resharding_destined_recipient_test.cpp
diff options
context:
space:
mode:
authorAlex Taskov <alex.taskov@mongodb.com>2020-11-06 10:41:04 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-06 15:59:26 +0000
commit6508f5d6ad5d514f433b660f0da7f513625973be (patch)
tree4f535c406e51f33fad14641556f5b689bfcdc141 /src/mongo/db/s/resharding_destined_recipient_test.cpp
parent5da1a52746a85a54b2809e8901da707a35d78e22 (diff)
downloadmongo-6508f5d6ad5d514f433b660f0da7f513625973be.tar.gz
SERVER-49825 Replicate updates changing value under new shard key pattern as delete + insert in a transaction
Diffstat (limited to 'src/mongo/db/s/resharding_destined_recipient_test.cpp')
-rw-r--r--src/mongo/db/s/resharding_destined_recipient_test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mongo/db/s/resharding_destined_recipient_test.cpp b/src/mongo/db/s/resharding_destined_recipient_test.cpp
index ba3579501de..7e3a1c9f3bc 100644
--- a/src/mongo/db/s/resharding_destined_recipient_test.cpp
+++ b/src/mongo/db/s/resharding_destined_recipient_test.cpp
@@ -216,6 +216,7 @@ protected:
_mockCatalogCacheLoader->setCollectionRefreshValues(
env.tempNss, collType, createChunks(env.version.epoch(), "y"), boost::none);
+ forceDatabaseRefresh(opCtx, kNss.db());
forceShardFilteringMetadataRefresh(opCtx, kNss);
if (refreshTempNss)
@@ -474,5 +475,35 @@ TEST_F(DestinedRecipientTest, TestOpObserverSetsDestinedRecipientOnDeletesInTran
ASSERT_EQ(*recipShard, env.destShard);
}
+TEST_F(DestinedRecipientTest, TestUpdateChangesOwningShardThrows) {
+ auto opCtx = operationContext();
+
+ DBDirectClient client(opCtx);
+ client.insert(kNss.toString(), BSON("_id" << 0 << "x" << 2 << "y" << 2 << "z" << 4));
+
+ auto env = setupReshardingEnv(opCtx, true);
+
+ ASSERT_THROWS(runInTransaction(
+ opCtx,
+ [&]() {
+ updateDoc(
+ opCtx, kNss, BSON("_id" << 0), BSON("$set" << BSON("y" << 50)), env);
+ }),
+ ExceptionFor<ErrorCodes::WouldChangeOwningShard>);
+}
+
+TEST_F(DestinedRecipientTest, TestUpdateSameOwningShard) {
+ auto opCtx = operationContext();
+
+ DBDirectClient client(opCtx);
+ client.insert(kNss.toString(), BSON("_id" << 0 << "x" << 2 << "y" << 2 << "z" << 4));
+
+ auto env = setupReshardingEnv(opCtx, true);
+
+ runInTransaction(opCtx, [&]() {
+ updateDoc(opCtx, kNss, BSON("_id" << 0), BSON("$set" << BSON("y" << 3)), env);
+ });
+}
+
} // namespace
} // namespace mongo