summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2022-02-15 08:33:37 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-14 22:27:59 +0000
commit9477a796309f42c468e57e9329f0cba7beaf5514 (patch)
treee80e26ab4cbca66a8464e24df67720d65663e6ee
parent77cb72e47349fe4fa81646a7a85b0f60bdc41c0f (diff)
downloadmongo-9477a796309f42c468e57e9329f0cba7beaf5514.tar.gz
Import wiredtiger: d55dc5ef84e4c5fc29a6b4502694bd0c20482be3 from branch mongodb-master
ref: 4375642a0f..d55dc5ef84 for: 5.3.0 WT-8776 Setting a read timestamp after prepare panics
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/txn/txn_timestamp.c22
-rw-r--r--src/third_party/wiredtiger/test/suite/test_prepare01.py12
3 files changed, 28 insertions, 8 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 4b5b2f6ea4e..17a2750e8d4 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": "4375642a0f5e1a1af55ad4a937c50b3bf2f0dd29"
+ "commit": "d55dc5ef84e4c5fc29a6b4502694bd0c20482be3"
}
diff --git a/src/third_party/wiredtiger/src/txn/txn_timestamp.c b/src/third_party/wiredtiger/src/txn/txn_timestamp.c
index a81a00cd17f..6e67a03c6f4 100644
--- a/src/third_party/wiredtiger/src/txn/txn_timestamp.c
+++ b/src/third_party/wiredtiger/src/txn/txn_timestamp.c
@@ -758,7 +758,15 @@ __wt_txn_set_read_timestamp(WT_SESSION_IMPL *session, wt_timestamp_t read_ts)
txn_global = &S2C(session)->txn_global;
txn_shared = WT_SESSION_TXN_SHARED(session);
- WT_RET(__wt_txn_context_prepare_check(session));
+ /*
+ * Silently ignore attempts to set the read timestamp after a transaction is prepared (if we
+ * error, the system will panic because an operation on a prepared transaction cannot fail).
+ */
+ if (F_ISSET(session->txn, WT_TXN_PREPARE)) {
+ __wt_errx(session,
+ "attempt to set the read timestamp after the transaction is prepared silently ignored");
+ return (0);
+ }
/* Read timestamps imply / require snapshot isolation. */
if (!F_ISSET(txn, WT_TXN_RUNNING))
@@ -854,7 +862,7 @@ __wt_txn_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[])
bool set_ts;
set_ts = false;
- commit_ts = durable_ts = prepare_ts = read_ts = 0;
+ commit_ts = durable_ts = prepare_ts = read_ts = WT_TS_NONE;
WT_TRET(__wt_txn_context_check(session, true));
@@ -883,30 +891,30 @@ __wt_txn_set_timestamp(WT_SESSION_IMPL *session, const char *cfg[])
WT_RET(__wt_txn_parse_timestamp(session, "prepare", &prepare_ts, &cval));
set_ts = true;
} else if (WT_STRING_MATCH("read_timestamp", ckey.str, ckey.len)) {
- WT_RET(__wt_txn_parse_timestamp(session, "durable", &read_ts, &cval));
+ WT_RET(__wt_txn_parse_timestamp(session, "read", &read_ts, &cval));
set_ts = true;
}
}
WT_RET_NOTFOUND_OK(ret);
/* Look for a commit timestamp. */
- if (commit_ts != 0)
+ if (commit_ts != WT_TS_NONE)
WT_RET(__wt_txn_set_commit_timestamp(session, commit_ts));
/*
* Look for a durable timestamp. Durable timestamp should be set only after setting the commit
* timestamp.
*/
- if (durable_ts != 0)
+ if (durable_ts != WT_TS_NONE)
WT_RET(__wt_txn_set_durable_timestamp(session, durable_ts));
__wt_txn_publish_durable_timestamp(session);
/* Look for a read timestamp. */
- if (read_ts != 0)
+ if (read_ts != WT_TS_NONE)
WT_RET(__wt_txn_set_read_timestamp(session, read_ts));
/* Look for a prepare timestamp. */
- if (prepare_ts != 0)
+ if (prepare_ts != WT_TS_NONE)
WT_RET(__wt_txn_set_prepare_timestamp(session, prepare_ts));
if (set_ts)
diff --git a/src/third_party/wiredtiger/test/suite/test_prepare01.py b/src/third_party/wiredtiger/test/suite/test_prepare01.py
index 5a4986d4881..1a98152d622 100644
--- a/src/third_party/wiredtiger/test/suite/test_prepare01.py
+++ b/src/third_party/wiredtiger/test/suite/test_prepare01.py
@@ -142,5 +142,17 @@ class test_prepare01(wttest.WiredTigerTestCase):
self.session.commit_transaction()
self.check(cursor, self.nentries, self.nentries)
+# Attempts to set the read timestamp after preparing the transaction should be ignored.
+class test_prepare01_read_ts(wttest.WiredTigerTestCase):
+ def test_prepare01_read_ts(self):
+ uri = 'table:prepare01_read_ts'
+ self.session.create(uri, 'key_format=S,value_format=S')
+ c = self.session.open_cursor(uri)
+ self.session.begin_transaction()
+ c['aaa'] = 'value'
+ self.session.prepare_transaction('prepare_timestamp=a')
+ with self.expectedStderrPattern('.*silently ignored.*'):
+ self.session.timestamp_transaction('read_timestamp=a')
+
if __name__ == '__main__':
wttest.run()