diff options
author | Benety Goh <benety@mongodb.com> | 2016-08-31 14:34:54 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2016-09-01 15:37:53 -0400 |
commit | 78270a9d4de08b4b841d2b8020bfb643b6719943 (patch) | |
tree | 2f67c6bd08ccc6cb9b6f593b2c8a622602307c94 /src/mongo/db/repl/oplog_fetcher.cpp | |
parent | 6263265b42aa78db3b7d7fb39d4f96eab3de3ab6 (diff) | |
download | mongo-78270a9d4de08b4b841d2b8020bfb643b6719943.tar.gz |
SERVER-25914 OplogFetcher should shutdown and join Fetcher at destruction
Diffstat (limited to 'src/mongo/db/repl/oplog_fetcher.cpp')
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp index f6f1e422718..75d1022104e 100644 --- a/src/mongo/db/repl/oplog_fetcher.cpp +++ b/src/mongo/db/repl/oplog_fetcher.cpp @@ -40,6 +40,7 @@ #include "mongo/rpc/metadata/server_selection_metadata.h" #include "mongo/stdx/mutex.h" #include "mongo/util/assert_util.h" +#include "mongo/util/destructor_guard.h" #include "mongo/util/fail_point_service.h" #include "mongo/util/log.h" #include "mongo/util/time_support.h" @@ -248,6 +249,10 @@ OplogFetcher::OplogFetcher(executor::TaskExecutor* exec, EnqueueDocumentsFn enqueueDocumentsFn, OnShutdownCallbackFn onShutdownCallbackFn) : _dataReplicatorExternalState(dataReplicatorExternalState), + _enqueueDocumentsFn(enqueueDocumentsFn), + _awaitDataTimeout(calculateAwaitDataTimeout(config)), + _onShutdownCallbackFn(onShutdownCallbackFn), + _lastFetched(lastFetched), _fetcher(exec, source, oplogNSS.db().toString(), @@ -255,11 +260,7 @@ OplogFetcher::OplogFetcher(executor::TaskExecutor* exec, stdx::bind( &OplogFetcher::_callback, this, stdx::placeholders::_1, stdx::placeholders::_3), uassertStatusOK(makeMetadataObject(config.getProtocolVersion() == 1LL)), - config.getElectionTimeoutPeriod()), - _enqueueDocumentsFn(enqueueDocumentsFn), - _awaitDataTimeout(calculateAwaitDataTimeout(config)), - _onShutdownCallbackFn(onShutdownCallbackFn), - _lastFetched(lastFetched) { + config.getElectionTimeoutPeriod()) { uassert(ErrorCodes::BadValue, "null last optime fetched", !lastFetched.opTime.isNull()); uassert(ErrorCodes::InvalidReplicaSetConfig, "uninitialized replica set configuration", @@ -270,6 +271,10 @@ OplogFetcher::OplogFetcher(executor::TaskExecutor* exec, readersCreatedStats.increment(); } +OplogFetcher::~OplogFetcher() { + DESTRUCTOR_GUARD(shutdown(); join();); +} + std::string OplogFetcher::toString() const { return str::stream() << "OplogReader -" << " last optime fetched: " << _lastFetched.opTime.toString() |