summaryrefslogtreecommitdiff
path: root/src/mongo/db
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-09-14 08:35:19 +0000
commitc94a993632dccda780e233f9e19f943c2a4f1707 (patch)
treeb685cc9a7de90c975e3e9e2cec9ad3e028fe32a2 /src/mongo/db
parentfdf878f2d224ac2786fff8bafe003c2ef4cb5b1b (diff)
downloadmongo-c94a993632dccda780e233f9e19f943c2a4f1707.tar.gz
SERVER-64730 Interrupt ongoing refreshes after entering into the critical section
(cherry picked from commit 343108041c5b3570e97418ee3204804535fbde4d)
Diffstat (limited to 'src/mongo/db')
-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
-rw-r--r--src/mongo/db/s/shard_filtering_metadata_refresh.cpp6
4 files changed, 17 insertions, 7 deletions
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp
index 8334f99b74b..ccf7c28de65 100644
--- a/src/mongo/db/s/collection_sharding_runtime.cpp
+++ b/src/mongo/db/s/collection_sharding_runtime.cpp
@@ -163,6 +163,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.
*/
diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
index 0a7cecfe632..802bddbc016 100644
--- a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
+++ b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
@@ -115,8 +115,7 @@ bool joinShardVersionOperation(OperationContext* opCtx,
try {
inRecoverOrRefresh->get(opCtx);
} catch (const ExceptionFor<ErrorCodes::ShardVersionRefreshCanceled>&) {
- // The ongoing refresh has finished, although it was canceled by a
- // 'clearFilteringMetadata'.
+ // The ongoing refresh has finished, although it was interrupted.
}
}
@@ -223,7 +222,8 @@ SharedSemiFuture<void> recoverRefreshShardVersion(ServiceContext* serviceContext
if (cancellationToken.isCanceled() &&
(status.isOK() || status == ErrorCodes::Interrupted)) {
uasserted(ErrorCodes::ShardVersionRefreshCanceled,
- "Shard version refresh canceled by a 'clearFilteringMetadata'");
+ "Shard version refresh canceled by an interruption, probably due to a "
+ "'clearFilteringMetadata'");
}
return status;
})