summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergi Mateo Bellido <sergi.mateo-bellido@mongodb.com>2022-09-07 18:02:01 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-13 12:31:31 +0000
commit7841ccaf02170df756499cbe3258171e4567db45 (patch)
tree46d57503146da21416a1f167b16f0b6dbba4b42d /src
parent45d0dc50a91c020c14562432b8bdfa2775928289 (diff)
downloadmongo-7841ccaf02170df756499cbe3258171e4567db45.tar.gz
SERVER-64730 Interrupt ongoing refreshes after entering into the critical section
(cherry picked from commit 343108041c5b3570e97418ee3204804535fbde4d)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/s/collection_sharding_runtime.cpp4
-rw-r--r--src/mongo/db/s/collection_sharding_runtime.h8
-rw-r--r--src/mongo/db/s/recoverable_critical_section_service.h6
3 files changed, 14 insertions, 4 deletions
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp
index 03be1ee7db7..3156d9a4e43 100644
--- a/src/mongo/db/s/collection_sharding_runtime.cpp
+++ b/src/mongo/db/s/collection_sharding_runtime.cpp
@@ -170,6 +170,10 @@ void CollectionShardingRuntime::checkShardVersionOrThrow(OperationContext* opCtx
void CollectionShardingRuntime::enterCriticalSectionCatchUpPhase(const CSRLock&,
const BSONObj& reason) {
_critSec.enterCriticalSectionCatchUpPhase(reason);
+
+ if (_shardVersionInRecoverOrRefresh) {
+ _shardVersionInRecoverOrRefresh->cancellationSource.cancel();
+ }
}
void CollectionShardingRuntime::enterCriticalSectionCommitPhase(const CSRLock&,
diff --git a/src/mongo/db/s/collection_sharding_runtime.h b/src/mongo/db/s/collection_sharding_runtime.h
index d97deb9bee6..9d35dded956 100644
--- a/src/mongo/db/s/collection_sharding_runtime.h
+++ b/src/mongo/db/s/collection_sharding_runtime.h
@@ -113,10 +113,10 @@ public:
* Marks the collection's filtering metadata as UNKNOWN, meaning that all attempts to check for
* shard version match will fail with StaleConfig errors in order to trigger an update.
*
+ * Interrupts any ongoing shard metadata refresh.
+ *
* It is safe to call this method with only an intent lock on the collection (as opposed to
- * setFilteringMetadata which requires exclusive), however note that clearing a collection's
- * filtering metadata will interrupt all in-progress orphan cleanups in which case orphaned data
- * will remain behind on disk.
+ * setFilteringMetadata which requires exclusive).
*/
void clearFilteringMetadata(OperationContext* opCtx);
@@ -125,6 +125,8 @@ public:
* with both the collection lock and CSRLock held in exclusive mode.
*
* In these methods, the CSRLock ensures concurrent access to the critical section.
+ *
+ * Entering into the Critical Section interrupts any ongoing filtering metadata refresh.
*/
void enterCriticalSectionCatchUpPhase(const CSRLock&, const BSONObj& reason);
void enterCriticalSectionCommitPhase(const CSRLock&, const BSONObj& reason);
diff --git a/src/mongo/db/s/recoverable_critical_section_service.h b/src/mongo/db/s/recoverable_critical_section_service.h
index d1953b27942..d9ef1c75195 100644
--- a/src/mongo/db/s/recoverable_critical_section_service.h
+++ b/src/mongo/db/s/recoverable_critical_section_service.h
@@ -57,6 +57,8 @@ public:
* specified namespace and reason. It works even if the namespace's current metadata are
* UNKNOWN.
*
+ * Entering into the Critical Section interrupts any ongoing filtering metadata refresh.
+ *
* It adds a doc to config.collectionCriticalSections with with writeConcern write concern.
*
* Do nothing if the collection critical section is taken for that nss and reason, and will
@@ -87,7 +89,9 @@ public:
/**
* Releases the recoverable critical section for the given nss and reason.
*
- * It removes a doc from config.collectionCriticalSections with writeConcern write concern.
+ * It removes a doc from config.collectionCriticalSections with writeConcern write concern. As
+ * part of the removal, the filtering information is cleared on secondary nodes. It is
+ * responsability of the caller to properly set the filtering information on the primary node.
*
* Do nothing if the collection critical section is not taken for that nss and reason.
*/