summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2019-01-31 02:10:28 -0500
committerSuganthi Mani <suganthi.mani@mongodb.com>2019-02-06 11:25:15 -0500
commit0b1c1f570bd5b916ef0661e376dfe4d27387d3c8 (patch)
tree6fae0276839b67f61bd321487c61bf846f21fe4b /src/mongo/db
parent29685e3b88423a503e048982d76e91727aaba8e1 (diff)
downloadmongo-0b1c1f570bd5b916ef0661e376dfe4d27387d3c8.tar.gz
SERVER-38519 Test transactions with new stepdown sequence.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/commands/txn_cmds.cpp9
-rw-r--r--src/mongo/db/curop_failpoint_helpers.cpp9
-rw-r--r--src/mongo/db/curop_failpoint_helpers.h7
3 files changed, 24 insertions, 1 deletions
diff --git a/src/mongo/db/commands/txn_cmds.cpp b/src/mongo/db/commands/txn_cmds.cpp
index 00279cb7dff..f1a90e63510 100644
--- a/src/mongo/db/commands/txn_cmds.cpp
+++ b/src/mongo/db/commands/txn_cmds.cpp
@@ -35,6 +35,7 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/txn_cmds_gen.h"
+#include "mongo/db/curop_failpoint_helpers.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/repl_client_info.h"
@@ -47,6 +48,8 @@ namespace {
MONGO_FAIL_POINT_DEFINE(participantReturnNetworkErrorForAbortAfterExecutingAbortLogic);
MONGO_FAIL_POINT_DEFINE(participantReturnNetworkErrorForCommitAfterExecutingCommitLogic);
+MONGO_FAIL_POINT_DEFINE(hangBeforeCommitingTxn);
+MONGO_FAIL_POINT_DEFINE(hangBeforeAbortingTxn);
class CmdCommitTxn : public BasicCommand {
public:
@@ -108,6 +111,9 @@ public:
"Transaction isn't in progress",
txnParticipant->inMultiDocumentTransaction());
+ CurOpFailpointHelpers::waitWhileFailPointEnabled(
+ &hangBeforeCommitingTxn, opCtx, "hangBeforeCommitingTxn");
+
auto optionalCommitTimestamp = cmd.getCommitTimestamp();
if (optionalCommitTimestamp) {
// commitPreparedTransaction will throw if the transaction is not prepared.
@@ -168,6 +174,9 @@ public:
"Transaction isn't in progress",
txnParticipant->inMultiDocumentTransaction());
+ CurOpFailpointHelpers::waitWhileFailPointEnabled(
+ &hangBeforeAbortingTxn, opCtx, "hangBeforeAbortingTxn");
+
txnParticipant->abortActiveTransaction(opCtx);
if (MONGO_FAIL_POINT(participantReturnNetworkErrorForAbortAfterExecutingAbortLogic)) {
diff --git a/src/mongo/db/curop_failpoint_helpers.cpp b/src/mongo/db/curop_failpoint_helpers.cpp
index fb78284f6f8..0cda54e880e 100644
--- a/src/mongo/db/curop_failpoint_helpers.cpp
+++ b/src/mongo/db/curop_failpoint_helpers.cpp
@@ -64,6 +64,7 @@ void CurOpFailpointHelpers::waitWhileFailPointEnabled(FailPoint* failPoint,
const bool shouldCheckForInterrupt =
checkForInterrupt || data["shouldCheckForInterrupt"].booleanSafe();
+ const bool shouldContinueOnInterrupt = data["shouldContinueOnInterrupt"].booleanSafe();
while (MONGO_FAIL_POINT((*failPoint))) {
sleepFor(Milliseconds(10));
if (whileWaiting) {
@@ -72,7 +73,13 @@ void CurOpFailpointHelpers::waitWhileFailPointEnabled(FailPoint* failPoint,
// Check for interrupt so that an operation can be killed while waiting for the
// failpoint to be disabled, if the failpoint is configured to be interruptible.
- if (shouldCheckForInterrupt) {
+ //
+ // For shouldContinueOnInterrupt, an interrupt merely allows the code to continue past
+ // the failpoint; it is up to the code under test to actually check for interrupt.
+ if (shouldContinueOnInterrupt) {
+ if (!opCtx->checkForInterruptNoAssert().isOK())
+ break;
+ } else if (shouldCheckForInterrupt) {
opCtx->checkForInterrupt();
}
}
diff --git a/src/mongo/db/curop_failpoint_helpers.h b/src/mongo/db/curop_failpoint_helpers.h
index 84f15caecb1..fb3b4608fef 100644
--- a/src/mongo/db/curop_failpoint_helpers.h
+++ b/src/mongo/db/curop_failpoint_helpers.h
@@ -50,6 +50,13 @@ public:
* whileWaiting() may be used to do anything the caller needs done while hanging in the
* failpoint. For example, the caller may use whileWaiting() to release and reacquire locks in
* order to avoid deadlocks.
+ *
+ * If checkForInterrupt is false, the field "shouldCheckForInterrupt" may be set to 'true' at
+ * runtime to cause this method to uassert on interrupt.
+ *
+ * The field "shouldContinueOnInterrupt" may be set to 'true' to cause this method to continue
+ * on interrupt without asserting, regardless of whether checkForInterrupt or the field
+ * "shouldCheckForInterrupt" is set.
*/
static void waitWhileFailPointEnabled(FailPoint* failPoint,
OperationContext* opCtx,