diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
|
index 64f38e6000..4db1c6337e 100644
|
--- a/src/mongo/db/service_entry_point_common.cpp
|
+++ b/src/mongo/db/service_entry_point_common.cpp
|
@@ -66,6 +66,7 @@
|
#include "mongo/db/s/shard_filtering_metadata_refresh.h"
|
#include "mongo/db/s/sharded_connection_info.h"
|
#include "mongo/db/s/sharding_state.h"
|
+#include "mongo/db/server_parameters.h"
|
#include "mongo/db/service_entry_point_common.h"
|
#include "mongo/db/session_catalog.h"
|
#include "mongo/db/stats/counters.h"
|
@@ -95,6 +96,8 @@ MONGO_FP_DECLARE(rsStopGetMore);
|
MONGO_FP_DECLARE(respondWithNotPrimaryInCommandDispatch);
|
MONGO_FP_DECLARE(skipCheckingForNotMasterInCommandDispatch);
|
|
+MONGO_EXPORT_SERVER_PARAMETER(allowSecondaryReadsDuringBatchApplication, bool, true);
|
+
|
namespace {
|
using logger::LogComponent;
|
|
@@ -727,6 +730,11 @@ void execCommandDatabase(OperationContext* opCtx,
|
}
|
|
behaviors.waitForReadConcern(opCtx, invocation.get(), request);
|
+ boost::optional<ShouldNotConflictWithSecondaryBatchApplicationBlock> noConflict;
|
+ if (
|
+ allowSecondaryReadsDuringBatchApplication.load()) {
|
+ noConflict.emplace(opCtx->lockState());
|
+ }
|
|
retval = runCommandImpl(
|
opCtx, invocation.get(), request, replyBuilder, startOperationTime, behaviors);
|