summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Osta <luis.osta@mongodb.com>2021-06-28 13:08:55 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-28 13:39:23 +0000
commit04a2a0050956a305c241a438b82a6d183a6df12a (patch)
tree3ad315880fdc56aeef5cbc87ae5353e4d2637663
parent458a49b61671fc42e64d66570da8f07c24fa8f19 (diff)
downloadmongo-04a2a0050956a305c241a438b82a6d183a6df12a.tar.gz
SERVER-57665 Remove the unused disallowWritesForResharding() method
-rw-r--r--src/mongo/db/s/collection_metadata.cpp51
-rw-r--r--src/mongo/db/s/collection_metadata.h8
-rw-r--r--src/mongo/db/s/collection_metadata_test.cpp72
-rw-r--r--src/mongo/db/s/scoped_collection_metadata.h4
4 files changed, 0 insertions, 135 deletions
diff --git a/src/mongo/db/s/collection_metadata.cpp b/src/mongo/db/s/collection_metadata.cpp
index c96a4848842..76eb80b516a 100644
--- a/src/mongo/db/s/collection_metadata.cpp
+++ b/src/mongo/db/s/collection_metadata.cpp
@@ -103,57 +103,6 @@ void CollectionMetadata::throwIfReshardingInProgress(NamespaceString const& nss)
}
}
-bool CollectionMetadata::disallowWritesForResharding(const UUID& currentCollectionUUID) const {
- if (!isSharded())
- return false;
-
- const auto& reshardingFields = getReshardingFields();
- if (!reshardingFields)
- return false;
-
- switch (reshardingFields->getState()) {
- case CoordinatorStateEnum::kUnused:
- case CoordinatorStateEnum::kInitializing:
- case CoordinatorStateEnum::kPreparingToDonate:
- case CoordinatorStateEnum::kCloning:
- case CoordinatorStateEnum::kApplying:
- return false;
- case CoordinatorStateEnum::kBlockingWrites:
- // Only return true if this is also the donor shard.
- return reshardingFields->getDonorFields() != boost::none;
- case CoordinatorStateEnum::kAborting:
- return false;
- case CoordinatorStateEnum::kCommitting:
- break;
- case CoordinatorStateEnum::kDone:
- return false;
- }
-
- const auto& recipientFields = reshardingFields->getRecipientFields();
- uassert(5325800,
- "Missing 'recipientFields' in collection metadata for resharding operation that has "
- "decision persisted",
- recipientFields);
-
- const auto& originalUUID = recipientFields->getSourceUUID();
- const auto& reshardingUUID = reshardingFields->getReshardingUUID();
-
- if (currentCollectionUUID == originalUUID) {
- // This shard must be both a donor and recipient. Neither the drop or renameCollection have
- // happened yet. Writes should continue to be disallowed.
- return true;
- } else if (currentCollectionUUID == reshardingUUID) {
- // The renameCollection has happened. Writes no longer need be disallowed on this shard.
- return false;
- }
-
- uasserted(ErrorCodes::InvalidUUID,
- "Expected collection to have either the original UUID {} or the resharding UUID {}, "
- "but the collection instead has UUID {}"_format(originalUUID.toString(),
- reshardingUUID.toString(),
- currentCollectionUUID.toString()));
-}
-
BSONObj CollectionMetadata::extractDocumentKey(const BSONObj& doc) const {
BSONObj key;
diff --git a/src/mongo/db/s/collection_metadata.h b/src/mongo/db/s/collection_metadata.h
index 74a71cd639a..aeae9303eb5 100644
--- a/src/mongo/db/s/collection_metadata.h
+++ b/src/mongo/db/s/collection_metadata.h
@@ -83,14 +83,6 @@ public:
void throwIfReshardingInProgress(NamespaceString const& nss) const;
/**
- * The caller should disallow writes when
- * 1. The coordinator is in the mirroring state, OR
- * 2. The coordinator is in the decision persisted state, but the UUID is still the
- * original UUID.
- */
- bool disallowWritesForResharding(const UUID& currentCollectionUUID) const;
-
- /**
* Returns the current shard version for the collection or UNSHARDED if it is not sharded.
*
* Will throw ShardInvalidatedForTargeting if _thisShardId is marked as stale by
diff --git a/src/mongo/db/s/collection_metadata_test.cpp b/src/mongo/db/s/collection_metadata_test.cpp
index b57ce9452fe..0b8bd1a2bbf 100644
--- a/src/mongo/db/s/collection_metadata_test.cpp
+++ b/src/mongo/db/s/collection_metadata_test.cpp
@@ -204,78 +204,6 @@ TEST_F(NoChunkFixture, OrphanedDataRangeEnd) {
ASSERT(!metadata.getNextOrphanRange(pending, metadata.getMaxKey()));
}
-TEST_F(NoChunkFixture, DisallowWritesInDecisionPersistedWithOrigUUID) {
- UUID originalUUID = UUID::gen();
- UUID reshardingUUID = UUID::gen();
-
- auto metadata =
- makeCollectionMetadata(originalUUID, reshardingUUID, CoordinatorStateEnum::kCommitting);
-
- // Writes should be disallowed if the collection metadata's UUID matches the original
- // collection's UUID.
- ASSERT(metadata.disallowWritesForResharding(originalUUID));
-}
-
-TEST_F(NoChunkFixture, AllowWritesInDecisionPersistedWithReshardingUUID) {
- UUID originalUUID = UUID::gen();
- UUID reshardingUUID = UUID::gen();
-
- auto metadata =
- makeCollectionMetadata(originalUUID, reshardingUUID, CoordinatorStateEnum::kCommitting);
-
- // Writes should NOT be disallowed when the UUID matches the temp collection's
- // UUID.
- ASSERT(!metadata.disallowWritesForResharding(reshardingUUID));
-}
-
-TEST_F(NoChunkFixture, DisallowWritesInDecisionPersistedThrows) {
- UUID originalUUID = UUID::gen();
- UUID reshardingUUID = UUID::gen();
- UUID rogueUUID = UUID::gen();
-
- auto metadata =
- makeCollectionMetadata(originalUUID, reshardingUUID, CoordinatorStateEnum::kCommitting);
-
- // If the collection's UUID matches neither the original UUID nor the resharding UUID,
- // expect an exception.
- ASSERT_THROWS_CODE(metadata.disallowWritesForResharding(rogueUUID),
- AssertionException,
- ErrorCodes::InvalidUUID);
-}
-
-TEST_F(NoChunkFixture, DisallowWritesInApplyingWithOrigUUID) {
- UUID originalUUID = UUID::gen();
- UUID reshardingUUID = UUID::gen();
-
- auto metadata =
- makeCollectionMetadata(originalUUID, reshardingUUID, CoordinatorStateEnum::kApplying);
-
- // Writes should NOT be disallowed if the coordinator state is applying.
- ASSERT(!metadata.disallowWritesForResharding(originalUUID));
-}
-
-TEST_F(NoChunkFixture, DisallowWritesInBlockingWritesWithOrigUUID) {
- UUID originalUUID = UUID::gen();
- UUID reshardingUUID = UUID::gen();
-
- auto metadata =
- makeCollectionMetadata(originalUUID, reshardingUUID, CoordinatorStateEnum::kBlockingWrites);
-
- // Writes should be disallowed if the coordinator state is blocking-writes.
- ASSERT(metadata.disallowWritesForResharding(originalUUID));
-}
-
-TEST_F(NoChunkFixture, DisallowWritesInErrorWithOrigUUID) {
- UUID originalUUID = UUID::gen();
- UUID reshardingUUID = UUID::gen();
-
- auto metadata =
- makeCollectionMetadata(originalUUID, reshardingUUID, CoordinatorStateEnum::kAborting);
-
- // Writes should NOT be disallowed if the coordinator state is error.
- ASSERT(!metadata.disallowWritesForResharding(originalUUID));
-}
-
/**
* Fixture with single chunk containing:
* [10->20)
diff --git a/src/mongo/db/s/scoped_collection_metadata.h b/src/mongo/db/s/scoped_collection_metadata.h
index 6977e9733bf..a2772b123dc 100644
--- a/src/mongo/db/s/scoped_collection_metadata.h
+++ b/src/mongo/db/s/scoped_collection_metadata.h
@@ -57,10 +57,6 @@ public:
return _impl->get().isSharded();
}
- bool disallowWritesForResharding(const UUID& currentCollectionUUID) const {
- return _impl->get().disallowWritesForResharding(currentCollectionUUID);
- }
-
bool isValidKey(const BSONObj& key) const {
return _impl->get().isValidKey(key);
}