summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2023-05-11 07:12:33 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-05-11 07:55:49 +0000
commit515c5d6a658810648275079c038365c47d21bbb1 (patch)
tree25164d95cf36acb477333e5edd89d151e0c833a2
parentc21700aadbcdbbbd79f40713f89cc37c2174e49e (diff)
downloadmongo-515c5d6a658810648275079c038365c47d21bbb1.tar.gz
SERVER-76835 Avoid blocking on PBWM and admission control tickets on the sharding metadata refresh path
-rw-r--r--src/mongo/db/s/shard_filtering_metadata_refresh.cpp7
-rw-r--r--src/mongo/db/s/shard_server_catalog_cache_loader.cpp16
2 files changed, 18 insertions, 5 deletions
diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
index 52338889bf1..ba01b41f2e3 100644
--- a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
+++ b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
@@ -489,6 +489,13 @@ void onCollectionPlacementVersionMismatch(OperationContext* opCtx,
boost::optional<SharedSemiFuture<void>> inRecoverOrRefresh;
{
+ // The refresh threads do not perform any data reads themselves, therefore they don't
+ // need to synchronise with secondary oplog application or go through admission control.
+ ShouldNotConflictWithSecondaryBatchApplicationBlock skipParallelBatchWriterMutex(
+ opCtx->lockState());
+ ScopedAdmissionPriorityForLock skipAdmissionControl(
+ opCtx->lockState(), AdmissionContext::Priority::kImmediate);
+
boost::optional<Lock::DBLock> dbLock;
boost::optional<Lock::CollectionLock> collLock;
dbLock.emplace(opCtx, nss.dbName(), MODE_IS);
diff --git a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp
index fd654f84dee..c3f0ad9d603 100644
--- a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp
+++ b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp
@@ -696,11 +696,6 @@ StatusWith<CollectionAndChangedChunks> ShardServerCatalogCacheLoader::_runSecond
// Read the local metadata.
- // Disallow reading on an older snapshot because this relies on being able to read the
- // side effects of writes during secondary replication after being signalled from the
- // CollectionPlacementVersionLogOpHandler.
- BlockSecondaryReadsDuringBatchApplication_DONT_USE secondaryReadsBlockBehindReplication(opCtx);
-
return _getCompletePersistedMetadataForSecondarySinceVersion(
opCtx, nss, catalogCacheSinceVersion);
}
@@ -1336,6 +1331,17 @@ ShardServerCatalogCacheLoader::_getCompletePersistedMetadataForSecondarySinceVer
// Keep trying to load the metadata until we get a complete view without updates being
// concurrently applied.
while (true) {
+ // Disallow reading on an older snapshot because this relies on being able to read the
+ // side effects of writes during secondary replication after being signalled from the
+ // CollectionPlacementVersionLogOpHandler.
+ BlockSecondaryReadsDuringBatchApplication_DONT_USE secondaryReadsBlockBehindReplication(
+ opCtx);
+
+ // Taking the PBWM and blocking on admission control can lead to deadlock with prepared
+ // transactions, so have internal refresh operations skip admission control
+ ScopedAdmissionPriorityForLock skipAdmissionControl(opCtx->lockState(),
+ AdmissionContext::Priority::kImmediate);
+
const auto beginRefreshState = [&]() {
while (true) {
auto notif = _namespaceNotifications.createNotification(nss);