summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/operation_sharding_state.h
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2022-03-10 09:14:47 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-10 10:00:45 +0000
commitd03d37af8b5ef60d828579e537ae0aab1f290719 (patch)
tree7d1ca1cf2e4db324be8a5ee2655c12f76e253023 /src/mongo/db/s/operation_sharding_state.h
parentdb137621456c0db1e8e2362c525e347433a0f43f (diff)
downloadmongo-d03d37af8b5ef60d828579e537ae0aab1f290719.tar.gz
SERVER-63327 Make the Stale* exception handling uniform in all code paths
Diffstat (limited to 'src/mongo/db/s/operation_sharding_state.h')
-rw-r--r--src/mongo/db/s/operation_sharding_state.h45
1 files changed, 7 insertions, 38 deletions
diff --git a/src/mongo/db/s/operation_sharding_state.h b/src/mongo/db/s/operation_sharding_state.h
index 63c726fcc0b..7a9a20012bb 100644
--- a/src/mongo/db/s/operation_sharding_state.h
+++ b/src/mongo/db/s/operation_sharding_state.h
@@ -146,37 +146,15 @@ public:
boost::optional<DatabaseVersion> getDbVersion(StringData dbName) const;
/**
- * This call is a no op if there isn't a currently active migration critical section. Otherwise
- * it will wait for the critical section to complete up to the remaining operation time.
+ * This method implements a best-effort attempt to wait for the critical section to complete
+ * before returning to the router at the previous step in order to prevent it from busy spinning
+ * while the critical section is in progress.
*
- * Returns true if the call actually waited because of migration critical section (regardless if
- * whether it timed out or not), false if there was no active migration critical section.
+ * All waits for migration critical section should go through this code path, because it also
+ * accounts for transactions and locking.
*/
- bool waitForMigrationCriticalSectionSignal(OperationContext* opCtx);
-
- /**
- * Setting this value indicates that when the version check failed, there was an active
- * migration for the namespace and that it would be prudent to wait for the critical section to
- * complete before retrying so the router doesn't make wasteful requests.
- */
- void setMigrationCriticalSectionSignal(boost::optional<SharedSemiFuture<void>> critSecSignal);
-
- /**
- * This call is a no op if there isn't a currently active movePrimary critical section.
- * Otherwise it will wait for the critical section to complete up to the remaining operation
- * time.
- *
- * Returns true if the call actually waited because of movePrimary critical section (regardless
- * whether it timed out or not), false if there was no active movePrimary critical section.
- */
- bool waitForMovePrimaryCriticalSectionSignal(OperationContext* opCtx);
-
- /**
- * Setting this value indicates that when the version check failed, there was an active
- * movePrimary for the namespace and that it would be prudent to wait for the critical section
- * to complete before retrying so the router doesn't make wasteful requests.
- */
- void setMovePrimaryCriticalSectionSignal(boost::optional<SharedSemiFuture<void>> critSecSignal);
+ static Status waitForCriticalSectionToComplete(OperationContext* opCtx,
+ SharedSemiFuture<void> critSecSignal) noexcept;
/**
* Stores the failed status in _shardingOperationFailedStatus.
@@ -221,15 +199,6 @@ private:
};
StringMap<DatabaseVersionTracker> _databaseVersions;
- // This value will only be non-null if version check during the operation execution failed due
- // to stale version and there was a migration for that namespace, which was in critical section.
- boost::optional<SharedSemiFuture<void>> _migrationCriticalSectionSignal;
-
- // This value will only be non-null if version check during the operation execution failed due
- // to stale version and there was a movePrimary for that namespace, which was in critical
- // section.
- boost::optional<SharedSemiFuture<void>> _movePrimaryCriticalSectionSignal;
-
// This value can only be set when a rerouting exception occurs during a write operation, and
// must be handled before this object gets destructed.
boost::optional<Status> _shardingOperationFailedStatus;