summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2020-04-21 09:41:13 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-21 13:54:31 +0000
commit1b18276d8c980dbe14e5f44f216d40b02904374e (patch)
tree8b4c95e5d5106d9f15025b73b5977e122f5c8f56
parent2ffb78633903ee629f14bc170b8aaab1fc5d5a18 (diff)
downloadmongo-1b18276d8c980dbe14e5f44f216d40b02904374e.tar.gz
SERVER-47600 Clear _receivingChunks on setFCV after metadata refresh
(cherry picked from commit 5943a22ad1a7bc8c8bc0a855087a9992ef4a2524)
-rw-r--r--src/mongo/db/s/collection_sharding_runtime.cpp6
-rw-r--r--src/mongo/db/s/collection_sharding_runtime.h5
-rw-r--r--src/mongo/db/s/metadata_manager.cpp5
-rw-r--r--src/mongo/db/s/metadata_manager.h5
-rw-r--r--src/mongo/db/s/migration_util.cpp9
5 files changed, 30 insertions, 0 deletions
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp
index 5cf6cf99568..0130c1d2f23 100644
--- a/src/mongo/db/s/collection_sharding_runtime.cpp
+++ b/src/mongo/db/s/collection_sharding_runtime.cpp
@@ -411,6 +411,12 @@ void CollectionShardingRuntime::appendInfoForServerStatus(BSONArrayBuilder* buil
}
}
+void CollectionShardingRuntime::clearReceivingChunks() {
+ stdx::lock_guard lk(_metadataManagerLock);
+ invariant(_metadataType == MetadataType::kSharded);
+ _metadataManager->clearReceivingChunks();
+}
+
CollectionCriticalSection::CollectionCriticalSection(OperationContext* opCtx, NamespaceString ns)
: _nss(std::move(ns)), _opCtx(opCtx) {
AutoGetCollection autoColl(_opCtx,
diff --git a/src/mongo/db/s/collection_sharding_runtime.h b/src/mongo/db/s/collection_sharding_runtime.h
index ddbf9683b7f..009e012441f 100644
--- a/src/mongo/db/s/collection_sharding_runtime.h
+++ b/src/mongo/db/s/collection_sharding_runtime.h
@@ -159,6 +159,11 @@ public:
_metadataManager->toBSONPending(bb);
}
+ /**
+ * Clears the list of chunks that are being received as a part of an incoming migration.
+ */
+ void clearReceivingChunks();
+
std::uint64_t getNumMetadataManagerChanges_forTest() {
return _numMetadataManagerChanges;
}
diff --git a/src/mongo/db/s/metadata_manager.cpp b/src/mongo/db/s/metadata_manager.cpp
index ff8b1032197..84bf965a0b9 100644
--- a/src/mongo/db/s/metadata_manager.cpp
+++ b/src/mongo/db/s/metadata_manager.cpp
@@ -560,4 +560,9 @@ SharedSemiFuture<void> MetadataManager::_submitRangeForDeletion(
});
return cleanupComplete;
}
+
+void MetadataManager::clearReceivingChunks() {
+ stdx::lock_guard<Latch> lg(_managerLock);
+ _receivingChunks.clear();
+}
} // namespace mongo
diff --git a/src/mongo/db/s/metadata_manager.h b/src/mongo/db/s/metadata_manager.h
index 27049e16490..832fb7aade7 100644
--- a/src/mongo/db/s/metadata_manager.h
+++ b/src/mongo/db/s/metadata_manager.h
@@ -114,6 +114,11 @@ public:
}
/**
+ * Clears the items in the _receivingChunks list.
+ */
+ void clearReceivingChunks();
+
+ /**
* Appends information on all the chunk ranges in rangesToClean to builder.
*/
void append(BSONObjBuilder* builder) const;
diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp
index c6ece1ae744..8cd12d652e3 100644
--- a/src/mongo/db/s/migration_util.cpp
+++ b/src/mongo/db/s/migration_util.cpp
@@ -409,6 +409,15 @@ void submitOrphanRanges(OperationContext* opCtx, const NamespaceString& nss, con
if (version == ChunkVersion::UNSHARDED())
return;
+ // We clear the list of receiving chunks to ensure that that a RangeDeletionTask submitted
+ // by this setFCV command cannot be blocked behind a chunk received as a part of a
+ // migration that completed on the recipient (this node) but failed to commit.
+ {
+ AutoGetCollection autoColl(opCtx, nss, MODE_IS);
+ auto csr = CollectionShardingRuntime::get(opCtx, nss);
+ csr->clearReceivingChunks();
+ }
+
LOGV2_DEBUG(22031,
2,
"Upgrade: Cleaning up existing orphans",