summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/bgsync.cpp
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2016-06-24 19:06:49 -0400
committerBenety Goh <benety@mongodb.com>2016-06-25 12:25:16 -0400
commit52f29d0dc82569e3fb8a008c418f50be2bc61844 (patch)
tree9547ab6333abbf2ad10f689b7d986f0e5c346c74 /src/mongo/db/repl/bgsync.cpp
parente48204e21c938a372c9cc6822b26ed0b1edbc3a0 (diff)
downloadmongo-52f29d0dc82569e3fb8a008c418f50be2bc61844.tar.gz
SERVER-24784 BackgroundSync checks local shutdown flag instead of global mongo::inShutdown()
Diffstat (limited to 'src/mongo/db/repl/bgsync.cpp')
-rw-r--r--src/mongo/db/repl/bgsync.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp
index bbd55204450..f01d1e4ac4b 100644
--- a/src/mongo/db/repl/bgsync.cpp
+++ b/src/mongo/db/repl/bgsync.cpp
@@ -56,7 +56,6 @@
#include "mongo/rpc/metadata/repl_set_metadata.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/concurrency/thread_pool.h"
-#include "mongo/util/exit.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
@@ -180,13 +179,14 @@ void BackgroundSync::shutdown(OperationContext* txn) {
stdx::lock_guard<stdx::mutex> lock(_mutex);
// Clear the buffer in case the producerThread is waiting in push() due to a full queue.
- invariant(inShutdown());
clearBuffer(txn);
_stopped = true;
if (_oplogFetcher) {
_oplogFetcher->shutdown();
}
+
+ _inShutdown = true;
}
void BackgroundSync::join(OperationContext* txn) {
@@ -196,6 +196,15 @@ void BackgroundSync::join(OperationContext* txn) {
_oplogBuffer->shutdown(txn);
}
+bool BackgroundSync::inShutdown() const {
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
+ return _inShutdown_inlock();
+}
+
+bool BackgroundSync::_inShutdown_inlock() const {
+ return _inShutdown;
+}
+
void BackgroundSync::_run() {
Client::initThread("rsBackgroundSync");
AuthorizationSession::get(cc())->grantInternalAuthorization();
@@ -279,7 +288,7 @@ void BackgroundSync::_produce(OperationContext* txn) {
}
if (_replCoord->isWaitingForApplierToDrain() || _replCoord->getMemberState().primary() ||
- inShutdownStrict()) {
+ _inShutdown_inlock()) {
return;
}
}