summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2021-12-30 15:53:23 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-30 05:17:45 +0000
commitc636b1e71274ae651808b9957c3b7f22f0d4b222 (patch)
tree306d789079338f684055f2ff6c42586e17774592
parent23166382f8f7d7c9ed322e590e5020d37a29b540 (diff)
downloadmongo-c636b1e71274ae651808b9957c3b7f22f0d4b222.tar.gz
Import wiredtiger: 562f6d57d38b218c7a5c12e8ddee39a87df71b03 from branch mongodb-master
ref: aab21d5814..562f6d57d3 for: 5.3.0 WT-8609 Return an error if there's an attempt to prepare a logged object rather than asserting
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/txn/txn.c6
-rw-r--r--src/third_party/wiredtiger/test/suite/test_prepare18.py52
3 files changed, 55 insertions, 5 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 5f480ff997f..1bdbecde458 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": "aab21d5814193dc1943d9f5e62fd40ad6973475a"
+ "commit": "562f6d57d38b218c7a5c12e8ddee39a87df71b03"
}
diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c
index b27ff605759..5f136e22783 100644
--- a/src/third_party/wiredtiger/src/txn/txn.c
+++ b/src/third_party/wiredtiger/src/txn/txn.c
@@ -1966,10 +1966,8 @@ __wt_txn_prepare(WT_SESSION_IMPL *session, const char *cfg[])
* A transaction should not have updated any of the logged tables, if debug mode logging is not
* turned on.
*/
- if (!FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_DEBUG_MODE))
- WT_RET_ASSERT(session, txn->logrec == NULL, EINVAL,
- "A transaction should not have been assigned a log record if WT_CONN_LOG_DEBUG mode is "
- "not enabled");
+ if (txn->logrec != NULL && !FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_DEBUG_MODE))
+ WT_RET_MSG(session, EINVAL, "a prepared transaction cannot include a logged table");
/* Set the prepare timestamp. */
WT_RET(__wt_txn_set_timestamp(session, cfg));
diff --git a/src/third_party/wiredtiger/test/suite/test_prepare18.py b/src/third_party/wiredtiger/test/suite/test_prepare18.py
new file mode 100644
index 00000000000..692077b28ce
--- /dev/null
+++ b/src/third_party/wiredtiger/test/suite/test_prepare18.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+#
+# Public Domain 2014-present MongoDB, Inc.
+# Public Domain 2008-2014 WiredTiger, Inc.
+#
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+import wiredtiger, wttest
+from wtdataset import SimpleDataSet
+
+# test_prepare18.py
+# Test that prepare on a logged file returns an error.
+class test_prepare18(wttest.WiredTigerTestCase):
+ conn_config = 'log=(enabled)'
+
+ def test_prepare18(self):
+ uri = "table:prepare18"
+ ds = SimpleDataSet(self, uri, 100, key_format='S', value_format='S')
+ ds.populate()
+ cursor = self.session.open_cursor(uri, None)
+ self.session.begin_transaction()
+ cursor[ds.key(10)] = ds.value(20)
+ self.session.commit_transaction()
+ self.session.begin_transaction()
+ cursor[ds.key(10)] = ds.value(20)
+ msg='/a prepared transaction cannot include a logged table/'
+ self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
+ lambda:self.session.prepare_transaction('prepare_timestamp=1'), msg)
+
+if __name__ == '__main__':
+ wttest.run()