summaryrefslogtreecommitdiff
path: root/src/mongo/executor
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2019-09-10 19:03:36 +0000
committerevergreen <evergreen@mongodb.com>2019-09-10 19:03:36 +0000
commit5a0f718e1309a4484580d8038016d043ef3b887f (patch)
tree7a331d57ba6e33e61f96ed69b2aa387003a039ab /src/mongo/executor
parentb9e29cd56ebc9aca06f68eeeda7c523d3dfd6d41 (diff)
downloadmongo-5a0f718e1309a4484580d8038016d043ef3b887f.tar.gz
SERVER-43119 FailPoint cleanup
- Don't use MONGO_INITIALIZER to declare each fail point. We only need one init task in total: freeze and iterate the registry. - remove MONGO_FAIL_POINT_DECLARE macro (extern) - remove MONGO_FAIL_POINT_SHOULD_FAIL macro (FailPoint::shouldFail) - remove MONGO_FAIL_POINT_BLOCK_IF (FailPoint::executeIf) - remove MONGO_FAIL_POINT_BLOCK (FailPoint::execute) - clean up FailPointRegistry and fail_point_service implementation.
Diffstat (limited to 'src/mongo/executor')
-rw-r--r--src/mongo/executor/network_interface.h4
-rw-r--r--src/mongo/executor/network_interface_tl.cpp4
-rw-r--r--src/mongo/executor/scoped_task_executor.cpp6
-rw-r--r--src/mongo/executor/scoped_task_executor.h6
-rw-r--r--src/mongo/executor/scoped_task_executor_test.cpp2
-rw-r--r--src/mongo/executor/thread_pool_task_executor.cpp10
-rw-r--r--src/mongo/executor/thread_pool_task_executor.h4
-rw-r--r--src/mongo/executor/thread_pool_task_executor_test.cpp12
8 files changed, 24 insertions, 24 deletions
diff --git a/src/mongo/executor/network_interface.h b/src/mongo/executor/network_interface.h
index 6f938efb3a1..09a7fdaeb75 100644
--- a/src/mongo/executor/network_interface.h
+++ b/src/mongo/executor/network_interface.h
@@ -42,8 +42,8 @@
namespace mongo {
namespace executor {
-MONGO_FAIL_POINT_DECLARE(networkInterfaceDiscardCommandsBeforeAcquireConn);
-MONGO_FAIL_POINT_DECLARE(networkInterfaceDiscardCommandsAfterAcquireConn);
+extern FailPoint networkInterfaceDiscardCommandsBeforeAcquireConn;
+extern FailPoint networkInterfaceDiscardCommandsAfterAcquireConn;
/**
* Interface to networking for use by TaskExecutor implementations.
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp
index 2cc0fc9244f..bcd1672e50e 100644
--- a/src/mongo/executor/network_interface_tl.cpp
+++ b/src/mongo/executor/network_interface_tl.cpp
@@ -286,7 +286,7 @@ Status NetworkInterfaceTL::startCommand(const TaskExecutor::CallbackHandle& cbHa
}
});
- if (MONGO_FAIL_POINT(networkInterfaceDiscardCommandsBeforeAcquireConn)) {
+ if (MONGO_unlikely(networkInterfaceDiscardCommandsBeforeAcquireConn.shouldFail())) {
log() << "Discarding command due to failpoint before acquireConn";
return Status::OK();
}
@@ -311,7 +311,7 @@ Status NetworkInterfaceTL::startCommand(const TaskExecutor::CallbackHandle& cbHa
// We have a connection and the command hasn't already been attempted
cmdState->request.emplace(cmdState->requestOnAny, idx);
- if (MONGO_FAIL_POINT(networkInterfaceDiscardCommandsAfterAcquireConn)) {
+ if (MONGO_unlikely(networkInterfaceDiscardCommandsAfterAcquireConn.shouldFail())) {
log() << "Discarding command due to failpoint after acquireConn";
return Status::OK();
}
diff --git a/src/mongo/executor/scoped_task_executor.cpp b/src/mongo/executor/scoped_task_executor.cpp
index a9b4e32dde8..e7e2f1bd5ae 100644
--- a/src/mongo/executor/scoped_task_executor.cpp
+++ b/src/mongo/executor/scoped_task_executor.cpp
@@ -215,10 +215,10 @@ private:
std::piecewise_construct, std::forward_as_tuple(id), std::forward_as_tuple());
};
- if (MONGO_FAIL_POINT(ScopedTaskExecutorHangBeforeSchedule)) {
+ if (MONGO_unlikely(ScopedTaskExecutorHangBeforeSchedule.shouldFail())) {
ScopedTaskExecutorHangBeforeSchedule.setMode(FailPoint::off);
- MONGO_FAIL_POINT_PAUSE_WHILE_SET(ScopedTaskExecutorHangExitBeforeSchedule);
+ ScopedTaskExecutorHangExitBeforeSchedule.pauseWhileSet();
}
// State 2 - Indeterminate state. We don't know yet if the task will get scheduled.
@@ -259,7 +259,7 @@ private:
doWorkAndNotify(args);
});
- MONGO_FAIL_POINT_PAUSE_WHILE_SET(ScopedTaskExecutorHangAfterSchedule);
+ ScopedTaskExecutorHangAfterSchedule.pauseWhileSet();
stdx::unique_lock lk(_mutex);
diff --git a/src/mongo/executor/scoped_task_executor.h b/src/mongo/executor/scoped_task_executor.h
index 89d6187808f..dc166606115 100644
--- a/src/mongo/executor/scoped_task_executor.h
+++ b/src/mongo/executor/scoped_task_executor.h
@@ -107,9 +107,9 @@ private:
std::shared_ptr<TaskExecutor> _executor;
};
-MONGO_FAIL_POINT_DECLARE(ScopedTaskExecutorHangBeforeSchedule);
-MONGO_FAIL_POINT_DECLARE(ScopedTaskExecutorHangExitBeforeSchedule);
-MONGO_FAIL_POINT_DECLARE(ScopedTaskExecutorHangAfterSchedule);
+extern FailPoint ScopedTaskExecutorHangBeforeSchedule;
+extern FailPoint ScopedTaskExecutorHangExitBeforeSchedule;
+extern FailPoint ScopedTaskExecutorHangAfterSchedule;
} // namespace executor
} // namespace mongo
diff --git a/src/mongo/executor/scoped_task_executor_test.cpp b/src/mongo/executor/scoped_task_executor_test.cpp
index ec078cb4dde..49c3842f392 100644
--- a/src/mongo/executor/scoped_task_executor_test.cpp
+++ b/src/mongo/executor/scoped_task_executor_test.cpp
@@ -288,7 +288,7 @@ TEST_F(ScopedTaskExecutorTest, scheduleLoseRaceWithShutdownOfUnderlying) {
.isOK());
});
- MONGO_FAIL_POINT_PAUSE_WHILE_SET((bfp));
+ (bfp).pauseWhileSet();
shutdownUnderlying();
diff --git a/src/mongo/executor/thread_pool_task_executor.cpp b/src/mongo/executor/thread_pool_task_executor.cpp
index 808b2a7350c..55adfc29984 100644
--- a/src/mongo/executor/thread_pool_task_executor.cpp
+++ b/src/mongo/executor/thread_pool_task_executor.cpp
@@ -420,7 +420,7 @@ StatusWith<TaskExecutor::CallbackHandle> ThreadPoolTaskExecutor::scheduleRemoteC
const RemoteCommandOnAnyCallbackFn& cb,
const BatonHandle& baton) {
- if (MONGO_FAIL_POINT(initialSyncFuzzerSynchronizationPoint1)) {
+ if (MONGO_unlikely(initialSyncFuzzerSynchronizationPoint1.shouldFail())) {
// We are only going to pause on these failpoints if the command issued is for the
// collection cloning part of initial sync.
const auto cmdName = request.cmdObj.firstElementFieldName();
@@ -431,11 +431,11 @@ StatusWith<TaskExecutor::CallbackHandle> ThreadPoolTaskExecutor::scheduleRemoteC
log() << "Collection Cloner scheduled a remote command on the " << request.dbname
<< " db: " << request.cmdObj;
log() << "initialSyncFuzzerSynchronizationPoint1 fail point enabled.";
- MONGO_FAIL_POINT_PAUSE_WHILE_SET(initialSyncFuzzerSynchronizationPoint1);
+ initialSyncFuzzerSynchronizationPoint1.pauseWhileSet();
- if (MONGO_FAIL_POINT(initialSyncFuzzerSynchronizationPoint2)) {
+ if (MONGO_unlikely(initialSyncFuzzerSynchronizationPoint2.shouldFail())) {
log() << "initialSyncFuzzerSynchronizationPoint2 fail point enabled.";
- MONGO_FAIL_POINT_PAUSE_WHILE_SET(initialSyncFuzzerSynchronizationPoint2);
+ initialSyncFuzzerSynchronizationPoint2.pauseWhileSet();
}
}
}
@@ -600,7 +600,7 @@ void ThreadPoolTaskExecutor::scheduleIntoPool_inlock(WorkQueue* fromQueue,
lk.unlock();
- if (MONGO_FAIL_POINT(scheduleIntoPoolSpinsUntilThreadPoolTaskExecutorShutsDown)) {
+ if (MONGO_unlikely(scheduleIntoPoolSpinsUntilThreadPoolTaskExecutorShutsDown.shouldFail())) {
scheduleIntoPoolSpinsUntilThreadPoolTaskExecutorShutsDown.setMode(FailPoint::off);
lk.lock();
diff --git a/src/mongo/executor/thread_pool_task_executor.h b/src/mongo/executor/thread_pool_task_executor.h
index 218987383cb..9106f596069 100644
--- a/src/mongo/executor/thread_pool_task_executor.h
+++ b/src/mongo/executor/thread_pool_task_executor.h
@@ -44,8 +44,8 @@ namespace mongo {
class ThreadPoolInterface;
namespace executor {
-MONGO_FAIL_POINT_DECLARE(initialSyncFuzzerSynchronizationPoint1);
-MONGO_FAIL_POINT_DECLARE(initialSyncFuzzerSynchronizationPoint2);
+extern FailPoint initialSyncFuzzerSynchronizationPoint1;
+extern FailPoint initialSyncFuzzerSynchronizationPoint2;
struct ConnectionPoolStats;
class NetworkInterface;
diff --git a/src/mongo/executor/thread_pool_task_executor_test.cpp b/src/mongo/executor/thread_pool_task_executor_test.cpp
index ed458e50a7c..fb7330ca3ee 100644
--- a/src/mongo/executor/thread_pool_task_executor_test.cpp
+++ b/src/mongo/executor/thread_pool_task_executor_test.cpp
@@ -215,11 +215,11 @@ TEST_F(ThreadPoolExecutorTest, ShutdownAndScheduleWorkRaceDoesNotCrash) {
})
.getStatus());
- auto fpTPTE1 = getGlobalFailPointRegistry()->getFailPoint(
- "scheduleIntoPoolSpinsUntilThreadPoolTaskExecutorShutsDown");
+ auto fpTPTE1 =
+ globalFailPointRegistry().find("scheduleIntoPoolSpinsUntilThreadPoolTaskExecutorShutsDown");
fpTPTE1->setMode(FailPoint::alwaysOn);
barrier.countDownAndWait();
- MONGO_FAIL_POINT_PAUSE_WHILE_SET((*fpTPTE1));
+ (*fpTPTE1).pauseWhileSet();
executor.shutdown();
executor.join();
ASSERT_OK(status1);
@@ -247,11 +247,11 @@ TEST_F(ThreadPoolExecutorTest, ShutdownAndScheduleRaceDoesNotCrash) {
amRunningRecursively = false;
});
- auto fpTPTE1 = getGlobalFailPointRegistry()->getFailPoint(
- "scheduleIntoPoolSpinsUntilThreadPoolTaskExecutorShutsDown");
+ auto fpTPTE1 =
+ globalFailPointRegistry().find("scheduleIntoPoolSpinsUntilThreadPoolTaskExecutorShutsDown");
fpTPTE1->setMode(FailPoint::alwaysOn);
barrier.countDownAndWait();
- MONGO_FAIL_POINT_PAUSE_WHILE_SET((*fpTPTE1));
+ (*fpTPTE1).pauseWhileSet();
executor.shutdown();
executor.join();
ASSERT_OK(status1);