diff options
author | Will Korteland <will.korteland@mongodb.com> | 2022-03-17 09:58:02 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-17 10:24:10 +0000 |
commit | f401a0e58d0d18283cff94185b8f1a6937b82dc6 (patch) | |
tree | 700d96f0e640e31ddae22049114c95347b34ab1c | |
parent | b25e3264c65277f70a9e8af97320dba695cf4c4e (diff) | |
download | mongo-f401a0e58d0d18283cff94185b8f1a6937b82dc6.tar.gz |
Import wiredtiger: 07e606fb66cc76a7f94664682201dee2627292fb from branch mongodb-master
ref: 2d852e2e17..07e606fb66
for: 6.0.0
Reverted ticket(s):
WT-8935 Failed transaction commit doesn't reset cursors.
-rw-r--r-- | src/third_party/wiredtiger/import.data | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/session/session_api.c | 31 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/txn/txn.c | 15 |
3 files changed, 31 insertions, 17 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 14d48c959c7..0fb253787a8 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": "2d852e2e1765e47486d1a85bd4422020d3feddc8" + "commit": "07e606fb66cc76a7f94664682201dee2627292fb" } diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c index f8a3d71872f..50fc6bdd0ad 100644 --- a/src/third_party/wiredtiger/src/session/session_api.c +++ b/src/third_party/wiredtiger/src/session/session_api.c @@ -1673,31 +1673,30 @@ __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_MSG(session, EINVAL, "failed %s transaction requires rollback%s%s", + if (F_ISSET(txn, WT_TXN_ERROR) && txn->mod_count != 0) { + __wt_err(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); - - F_SET(session, WT_SESSION_RESOLVING_TXN); - ret = __wt_txn_commit(session, cfg); - F_CLR(session, WT_SESSION_RESOLVING_TXN); + ret = EINVAL; + } err: /* - * 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. + * 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. */ - if (ret != 0 && F_ISSET(txn, WT_TXN_RUNNING)) { + 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 (F_ISSET(txn, WT_TXN_PREPARE)) - WT_TRET(__wt_panic( - session, ret, "failed to commit prepared transaction, failing the system")); + WT_RET_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 1737d15bf91..430e7417410 100644 --- a/src/third_party/wiredtiger/src/txn/txn.c +++ b/src/third_party/wiredtiger/src/txn/txn.c @@ -1720,6 +1720,12 @@ 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); @@ -1727,6 +1733,15 @@ 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); } |