summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorGabriel Marks <gabriel.marks@mongodb.com>2022-03-09 19:29:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-09 21:57:26 +0000
commit04010a3b4313f61031327298b07f490c6742dd9a (patch)
treee8c3084f99dc37d479fb064fc5b67dd963dd469e /src/mongo
parentcf8468372c4682b4d33d3c73ba4da1cbb9eafc70 (diff)
downloadmongo-04010a3b4313f61031327298b07f490c6742dd9a.tar.gz
SERVER-63456 Evaluate WriteBlockBypass in the op observer
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/s/SConscript3
-rw-r--r--src/mongo/db/s/global_user_write_block_state.cpp4
-rw-r--r--src/mongo/db/user_write_block_mode_op_observer_test.cpp6
3 files changed, 8 insertions, 5 deletions
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index 83da473ea76..214f4b658fc 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -31,6 +31,9 @@ env.Library(
'$BUILD_DIR/mongo/s/grid',
'$BUILD_DIR/mongo/s/sharding_routing_table',
],
+ LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/db/write_block_bypass'
+ ]
)
env.Library(
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 9843abf90d6..c7648075483 100644
--- a/src/mongo/db/s/global_user_write_block_state.cpp
+++ b/src/mongo/db/s/global_user_write_block_state.cpp
@@ -32,6 +32,7 @@
#include "mongo/platform/basic.h"
#include "mongo/db/s/global_user_write_block_state.h"
+#include "mongo/db/write_block_bypass.h"
namespace mongo {
@@ -60,7 +61,8 @@ void GlobalUserWriteBlockState::checkUserWritesAllowed(OperationContext* opCtx,
invariant(opCtx->lockState()->isLocked());
uassert(ErrorCodes::OperationFailed,
"User writes blocked",
- !_globalUserWritesBlocked || nss.isOnInternalDb());
+ !_globalUserWritesBlocked || WriteBlockBypass::get(opCtx).isWriteBlockBypassEnabled() ||
+ nss.isOnInternalDb());
}
} // namespace mongo
diff --git a/src/mongo/db/user_write_block_mode_op_observer_test.cpp b/src/mongo/db/user_write_block_mode_op_observer_test.cpp
index 72e2df3b3d1..dd64318a4a5 100644
--- a/src/mongo/db/user_write_block_mode_op_observer_test.cpp
+++ b/src/mongo/db/user_write_block_mode_op_observer_test.cpp
@@ -163,10 +163,8 @@ TEST_F(UserWriteBlockModeOpObserverTest, WriteBlockingEnabledWithBypass) {
WriteBlockBypass::get(opCtx.get()).setFromMetadata(opCtx.get(), BSONElement());
ASSERT(WriteBlockBypass::get(opCtx.get()).isWriteBlockBypassEnabled());
- // Ensure user writes still fail under these conditions
- // TODO SERVER-63456 After implementing bypass into OpObservers, this expectation will change to
- // success.
- runCUD(opCtx.get(), NamespaceString("a.b"), false);
+ // Ensure user writes succeed
+ runCUD(opCtx.get(), NamespaceString("a.b"), true);
runCUD(opCtx.get(), NamespaceString("admin"), true);
runCUD(opCtx.get(), NamespaceString("local"), true);
runCUD(opCtx.get(), NamespaceString("config"), true);