summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/global_user_write_block_state.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/s/global_user_write_block_state.cpp')
-rw-r--r--src/mongo/db/s/global_user_write_block_state.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/s/global_user_write_block_state.cpp b/src/mongo/db/s/global_user_write_block_state.cpp
index c7648075483..47422440e8a 100644
--- a/src/mongo/db/s/global_user_write_block_state.cpp
+++ b/src/mongo/db/s/global_user_write_block_state.cpp
@@ -65,4 +65,22 @@ void GlobalUserWriteBlockState::checkUserWritesAllowed(OperationContext* opCtx,
nss.isOnInternalDb());
}
+void GlobalUserWriteBlockState::enableUserShardedDDLBlocking(OperationContext* opCtx) {
+ invariant(serverGlobalParams.clusterRole == ClusterRole::ShardServer);
+ _userShardedDDLBlocked.store(true);
+}
+
+void GlobalUserWriteBlockState::disableUserShardedDDLBlocking(OperationContext* opCtx) {
+ _userShardedDDLBlocked.store(false);
+}
+
+void GlobalUserWriteBlockState::checkShardedDDLAllowedToStart(OperationContext* opCtx,
+ const NamespaceString& nss) const {
+ invariant(serverGlobalParams.clusterRole == ClusterRole::ShardServer);
+ uassert(ErrorCodes::OperationFailed,
+ "User writes blocked",
+ !_userShardedDDLBlocked.load() ||
+ WriteBlockBypass::get(opCtx).isWriteBlockBypassEnabled() || nss.isOnInternalDb());
+}
+
} // namespace mongo