summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/recoverable_critical_section_service.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/s/recoverable_critical_section_service.cpp')
-rw-r--r--src/mongo/db/s/recoverable_critical_section_service.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/s/recoverable_critical_section_service.cpp b/src/mongo/db/s/recoverable_critical_section_service.cpp
index 13c2a328793..99b459c2800 100644
--- a/src/mongo/db/s/recoverable_critical_section_service.cpp
+++ b/src/mongo/db/s/recoverable_critical_section_service.cpp
@@ -48,6 +48,20 @@
namespace mongo {
+namespace recoverable_critical_section_util {
+
+bool inRecoveryMode(OperationContext* opCtx) {
+ const auto replCoord = repl::ReplicationCoordinator::get(opCtx);
+ if (!replCoord->isReplEnabled()) {
+ return false;
+ }
+
+ const auto memberState = replCoord->getMemberState();
+ return memberState.startup() || memberState.startup2() || memberState.rollback();
+}
+
+} // namespace recoverable_critical_section_util
+
namespace {
const auto serviceDecorator =
ServiceContext::declareDecoration<RecoverableCriticalSectionService>();