summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Korteland <will.korteland@mongodb.com>2022-03-17 09:57:40 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-17 10:24:10 +0000
commitffff3c7c879a7dede4c7657fc572043bb37d0ffb (patch)
tree9ef026af620d8a03e4c93976835e44cc5ee7f131
parent3ec4631a7f16b76f7490ec8b68fc778c8c7416c3 (diff)
downloadmongo-ffff3c7c879a7dede4c7657fc572043bb37d0ffb.tar.gz
Import wiredtiger: b110b14318dedb0dea5e2760a2dd50722f30cb7b from branch mongodb-master
ref: 746e435bb1..b110b14318 for: 6.0.0 WT-8935 Failed transaction commit doesn't reset cursors.
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/session/session_api.c31
-rw-r--r--src/third_party/wiredtiger/src/txn/txn.c15
3 files changed, 17 insertions, 31 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 125345c11e8..6a8f3f70d21 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-master",
- "commit": "746e435bb142b8ae482be38f8a7ed7f4a0180a96"
+ "commit": "b110b14318dedb0dea5e2760a2dd50722f30cb7b"
}
diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c
index 50fc6bdd0ad..f8a3d71872f 100644
--- a/src/third_party/wiredtiger/src/session/session_api.c
+++ b/src/third_party/wiredtiger/src/session/session_api.c
@@ -1673,30 +1673,31 @@ __session_commit_transaction(WT_SESSION *wt_session, const char *config)
WT_ERR(__wt_txn_context_check(session, true));
/* Permit the commit if the transaction failed, but was read-only. */
- if (F_ISSET(txn, WT_TXN_ERROR) && txn->mod_count != 0) {
- __wt_err(session, EINVAL,
- "failed %s"
- "transaction requires rollback%s%s",
+ if (F_ISSET(txn, WT_TXN_ERROR) && txn->mod_count != 0)
+ WT_ERR_MSG(session, EINVAL, "failed %s transaction requires rollback%s%s",
F_ISSET(txn, WT_TXN_PREPARE) ? "prepared " : "", txn->rollback_reason == NULL ? "" : ": ",
txn->rollback_reason == NULL ? "" : txn->rollback_reason);
- ret = EINVAL;
- }
+
+ F_SET(session, WT_SESSION_RESOLVING_TXN);
+ ret = __wt_txn_commit(session, cfg);
+ F_CLR(session, WT_SESSION_RESOLVING_TXN);
err:
/*
- * We might have failed because an illegal configuration was specified or because there wasn't a
- * transaction running, and we check the former as part of the api macros before we check the
- * latter. Deal with it here: if there's an error and a transaction is running, roll it back.
+ * We can fail because of an illegal configuration, or there wasn't a transaction running, or
+ * because commit itself failed. Deal with it here: if there's an error and a transaction is
+ * still running, roll it back.
+ *
+ * Check for a prepared transaction, and quit: we can't ignore the error and we can't roll back
+ * a prepared transaction the application wanted to commit.
*/
- if (ret == 0) {
- F_SET(session, WT_SESSION_RESOLVING_TXN);
- ret = __wt_txn_commit(session, cfg);
- F_CLR(session, WT_SESSION_RESOLVING_TXN);
- } else if (F_ISSET(txn, WT_TXN_RUNNING)) {
+ if (ret != 0 && F_ISSET(txn, WT_TXN_RUNNING)) {
if (F_ISSET(txn, WT_TXN_PREPARE))
- WT_RET_PANIC(session, ret, "failed to commit prepared transaction, failing the system");
+ WT_TRET(__wt_panic(
+ session, ret, "failed to commit prepared transaction, failing the system"));
WT_TRET(__wt_session_reset_cursors(session, false));
+
F_SET(session, WT_SESSION_RESOLVING_TXN);
WT_TRET(__wt_txn_rollback(session, cfg));
F_CLR(session, WT_SESSION_RESOLVING_TXN);
diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c
index 430e7417410..1737d15bf91 100644
--- a/src/third_party/wiredtiger/src/txn/txn.c
+++ b/src/third_party/wiredtiger/src/txn/txn.c
@@ -1720,12 +1720,6 @@ err:
if (cursor != NULL)
WT_TRET(cursor->close(cursor));
- /*
- * If anything went wrong, roll back.
- *
- * !!!
- * Nothing can fail after this point.
- */
if (locked)
__wt_readunlock(session, &txn_global->visibility_rwlock);
@@ -1733,15 +1727,6 @@ err:
if (cannot_fail)
WT_RET_PANIC(session, ret,
"failed to commit a transaction after data corruption point, failing the system");
-
- /*
- * Check for a prepared transaction, and quit: we can't ignore the error and we can't roll back
- * a prepared transaction.
- */
- if (prepare)
- WT_RET_PANIC(session, ret, "failed to commit prepared transaction, failing the system");
-
- WT_TRET(__wt_txn_rollback(session, cfg));
return (ret);
}