summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/data_replicator.cpp22
-rw-r--r--src/mongo/db/repl/multiapplier.cpp8
-rw-r--r--src/mongo/db/repl/multiapplier.h6
-rw-r--r--src/mongo/db/repl/multiapplier_test.cpp18
4 files changed, 21 insertions, 33 deletions
diff --git a/src/mongo/db/repl/data_replicator.cpp b/src/mongo/db/repl/data_replicator.cpp
index 04f57e66a7d..d4ed089a90d 100644
--- a/src/mongo/db/repl/data_replicator.cpp
+++ b/src/mongo/db/repl/data_replicator.cpp
@@ -209,18 +209,6 @@ void swapAndJoin_inlock(UniqueLock* lock, T& uniquePtrToReset, const char* msg)
lock->lock();
}
-template <typename T>
-void swapAndWait_inlock(UniqueLock* lock, T& uniquePtrToReset, const char* msg) {
- if (!uniquePtrToReset) {
- return;
- }
- T tempPtr = std::move(uniquePtrToReset);
- lock->unlock();
- LOG(1) << msg << tempPtr->toString();
- tempPtr->wait();
- lock->lock();
-}
-
} // namespace
std::string toString(DataReplicatorState s) {
@@ -370,7 +358,7 @@ void DataReplicator::_resumeFinish(CallbackArgs cbData) {
void DataReplicator::_pauseApplier() {
LockGuard lk(_mutex);
if (_applier)
- _applier->wait();
+ _applier->join();
_applierPaused = true;
_applier.reset();
}
@@ -391,7 +379,7 @@ StatusWith<Timestamp> DataReplicator::flushAndPause() {
if (_applierActive) {
_applierPaused = true;
lk.unlock();
- _applier->wait();
+ _applier->join();
lk.lock();
}
return StatusWith<Timestamp>(_lastApplied.opTime.getTimestamp());
@@ -845,7 +833,7 @@ void DataReplicator::_cancelAllHandles_inlock() {
if (_oplogFetcher)
_oplogFetcher->shutdown();
if (_applier)
- _applier->cancel();
+ _applier->shutdown();
if (_reporter)
_reporter->shutdown();
if (_initialSyncState && _initialSyncState->dbsCloner &&
@@ -857,7 +845,7 @@ void DataReplicator::_cancelAllHandles_inlock() {
void DataReplicator::_waitOnAndResetAll_inlock(UniqueLock* lk) {
swapAndJoin_inlock(lk, _lastOplogEntryFetcher, "Waiting on fetcher (last oplog entry): ");
swapAndJoin_inlock(lk, _oplogFetcher, "Waiting on oplog fetcher: ");
- swapAndWait_inlock(lk, _applier, "Waiting on applier: ");
+ swapAndJoin_inlock(lk, _applier, "Waiting on applier: ");
swapAndJoin_inlock(lk, _reporter, "Waiting on reporter: ");
if (_initialSyncState) {
swapAndJoin_inlock(lk, _initialSyncState->dbsCloner, "Waiting on databases cloner: ");
@@ -1190,7 +1178,7 @@ Status DataReplicator::_scheduleApplyBatch_inlock(const Operations& ops) {
invariant(!(_applier && _applier->isActive()));
_applier = stdx::make_unique<MultiApplier>(_exec, ops, applierFn, multiApplyFn, lambda);
_applierActive = true;
- return _applier->start();
+ return _applier->startup();
}
Status DataReplicator::_scheduleFetch() {
diff --git a/src/mongo/db/repl/multiapplier.cpp b/src/mongo/db/repl/multiapplier.cpp
index a2588c474d7..ddf690e3897 100644
--- a/src/mongo/db/repl/multiapplier.cpp
+++ b/src/mongo/db/repl/multiapplier.cpp
@@ -63,7 +63,7 @@ MultiApplier::MultiApplier(executor::TaskExecutor* executor,
}
MultiApplier::~MultiApplier() {
- DESTRUCTOR_GUARD(cancel(); wait(););
+ DESTRUCTOR_GUARD(shutdown(); join(););
}
std::string MultiApplier::toString() const {
@@ -86,7 +86,7 @@ bool MultiApplier::isActive() const {
return _active;
}
-Status MultiApplier::start() {
+Status MultiApplier::startup() {
stdx::lock_guard<stdx::mutex> lk(_mutex);
if (_active) {
@@ -105,7 +105,7 @@ Status MultiApplier::start() {
return Status::OK();
}
-void MultiApplier::cancel() {
+void MultiApplier::shutdown() {
executor::TaskExecutor::CallbackHandle dbWorkCallbackHandle;
{
stdx::lock_guard<stdx::mutex> lk(_mutex);
@@ -122,7 +122,7 @@ void MultiApplier::cancel() {
}
}
-void MultiApplier::wait() {
+void MultiApplier::join() {
stdx::unique_lock<stdx::mutex> lk(_mutex);
while (_active) {
diff --git a/src/mongo/db/repl/multiapplier.h b/src/mongo/db/repl/multiapplier.h
index bbd7414f940..d7cfe4bb132 100644
--- a/src/mongo/db/repl/multiapplier.h
+++ b/src/mongo/db/repl/multiapplier.h
@@ -120,7 +120,7 @@ public:
/**
* Starts applier by scheduling initial db work to be run by the executor.
*/
- Status start();
+ Status startup();
/**
* Cancels current db work request.
@@ -128,13 +128,13 @@ public:
*
* Callback function may be invoked with an ErrorCodes::CallbackCanceled status.
*/
- void cancel();
+ void shutdown();
/**
* Waits for active database worker to complete.
* Returns immediately if applier is not active.
*/
- void wait();
+ void join();
private:
/**
diff --git a/src/mongo/db/repl/multiapplier_test.cpp b/src/mongo/db/repl/multiapplier_test.cpp
index 96eb72dfc44..e598da3d71e 100644
--- a/src/mongo/db/repl/multiapplier_test.cpp
+++ b/src/mongo/db/repl/multiapplier_test.cpp
@@ -160,12 +160,12 @@ TEST_F(MultiApplierTest, MultiApplierInvokesCallbackWithCallbackCanceledStatusUp
executor::NetworkInterfaceMock::InNetworkGuard guard(net);
// Executor cannot run multiApply callback while we are on the network thread.
- ASSERT_OK(multiApplier.start());
- multiApplier.cancel();
+ ASSERT_OK(multiApplier.startup());
+ multiApplier.shutdown();
net->runReadyNetworkOperations();
}
- multiApplier.wait();
+ multiApplier.join();
ASSERT_FALSE(multiApplyInvoked);
@@ -196,13 +196,13 @@ TEST_F(MultiApplierTest, MultiApplierPassesMultiApplyErrorToCallback) {
};
MultiApplier multiApplier(&getExecutor(), operations, applyOperation, multiApply, callback);
- ASSERT_OK(multiApplier.start());
+ ASSERT_OK(multiApplier.startup());
{
auto net = getNet();
executor::NetworkInterfaceMock::InNetworkGuard guard(net);
net->runReadyNetworkOperations();
}
- multiApplier.wait();
+ multiApplier.join();
ASSERT_TRUE(multiApplyInvoked);
@@ -234,13 +234,13 @@ TEST_F(MultiApplierTest, MultiApplierCatchesMultiApplyExceptionAndConvertsToCall
};
MultiApplier multiApplier(&getExecutor(), operations, applyOperation, multiApply, callback);
- ASSERT_OK(multiApplier.start());
+ ASSERT_OK(multiApplier.startup());
{
auto net = getNet();
executor::NetworkInterfaceMock::InNetworkGuard guard(net);
net->runReadyNetworkOperations();
}
- multiApplier.wait();
+ multiApplier.join();
ASSERT_TRUE(multiApplyInvoked);
@@ -276,13 +276,13 @@ TEST_F(
};
MultiApplier multiApplier(&getExecutor(), operations, applyOperation, multiApply, callback);
- ASSERT_OK(multiApplier.start());
+ ASSERT_OK(multiApplier.startup());
{
auto net = getNet();
executor::NetworkInterfaceMock::InNetworkGuard guard(net);
net->runReadyNetworkOperations();
}
- multiApplier.wait();
+ multiApplier.join();
ASSERT_TRUE(multiApplyTxn);
ASSERT_EQUALS(1U, operationsToApply.size());