summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test
diff options
context:
space:
mode:
authorAlison Felizzi <alison.felizzi@mongodb.com>2022-01-20 06:09:34 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-20 06:40:01 +0000
commit642bf716d84facac62a36fe247bf60c7821a8d6e (patch)
treecf7b2763c98b3cc54c5b912b7d5ccda21bd9bb12 /src/third_party/wiredtiger/test
parent1a14fcf6f87827584ea5624b84a14247ef38dde9 (diff)
downloadmongo-642bf716d84facac62a36fe247bf60c7821a8d6e.tar.gz
Import wiredtiger: 85f16d6331a66fc6f5e2767dce40ccedce7f9f7d from branch mongodb-master
ref: c9247ed856..85f16d6331 for: 5.3.0 WT-8365 Improve performance for timestamp_transaction
Diffstat (limited to 'src/third_party/wiredtiger/test')
-rwxr-xr-x[-rw-r--r--]src/third_party/wiredtiger/test/suite/test_debug_mode03.py68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/third_party/wiredtiger/test/suite/test_debug_mode03.py b/src/third_party/wiredtiger/test/suite/test_debug_mode03.py
index 34640d63712..3b0ad8ad694 100644..100755
--- a/src/third_party/wiredtiger/test/suite/test_debug_mode03.py
+++ b/src/third_party/wiredtiger/test/suite/test_debug_mode03.py
@@ -26,7 +26,10 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
-import wiredtiger, wttest
+import struct, wiredtiger, wttest
+
+def timestamp(kind, ts):
+ return "{}_timestamp={:X}".format(kind, ts)
# test_debug_mode03.py
# Test the debug mode settings. Test table_logging use.
@@ -44,6 +47,11 @@ class test_debug_mode03(wttest.WiredTigerTestCase):
c[k] = self.value
c.close()
+ def add_data_at_ts(self, ts):
+ self.session.begin_transaction()
+ self.add_data()
+ self.session.commit_transaction(timestamp("commit", ts))
+
def find_log_recs(self):
# Open a log cursor. We should find log records that have
# the value we inserted.
@@ -61,6 +69,39 @@ class test_debug_mode03(wttest.WiredTigerTestCase):
c.close()
return count
+ def pack_large_int(self, large):
+ # This line in intpacking.py tells us how to pack a large integer:
+ #
+ # First byte | Next bytes | Min Value | Max Value
+ # [11 10llll] | l | 2^13 + 2^6 | 2^64 - 1
+ #
+ # An 8 byte integer is packed as byte 0xe8, followed by 8 bytes packed for big endian.
+ LARGE_INT = 2**13 + 2**6
+ self.assertGreaterEqual(large, LARGE_INT)
+ packed_int = b'\xe8' + struct.pack('>Q', large - LARGE_INT) # >Q == 8 bytes big endian
+ return packed_int
+
+ def find_ts_log_rec(self, ts):
+ # The timestamp we're looking for will be encoded as a 'packed integer' in the log file. We
+ # don't need a general purpose encoder here, we just need to know how to pack large integers.
+ packed_int = self.pack_large_int(ts)
+
+ # Open a log cursor, and we look for the timestamp somewhere in the values.
+ c = self.session.open_cursor("log:", None)
+ count = 0
+ while c.next() == 0:
+ # lsn.file, lsn.offset, opcount
+ keys = c.get_key()
+ # txnid, rectype, optype, fileid, logrec_key, logrec_value
+ values = c.get_value()
+
+ #self.tty('LOG: keys={}, values={}\n val5={}\n packed={}'.format(
+ # str(keys), str(values), values[5].hex(), packed_int.hex()))
+ if packed_int in values[5]: # logrec_value
+ count += 1
+ c.close()
+ return count
+
def test_table_logging(self):
self.session.create(self.uri, 'key_format=i,value_format=u,log=(enabled=false)')
self.add_data()
@@ -75,5 +116,30 @@ class test_debug_mode03(wttest.WiredTigerTestCase):
count = self.find_log_recs()
self.assertEqual(count, 0)
+ # Debug table logging with operations from timestamp_transaction
+ def test_table_logging_ts(self):
+ # We pick a large timestamp because encoding a large integer is relatively easy
+ # and we won't get any false positives when searching the log file.
+ base_ts = 0x1020304050600000
+
+ self.session.create(self.uri, 'key_format=i,value_format=u,log=(enabled=false)')
+ self.add_data_at_ts(base_ts + 0x100)
+
+ self.session.begin_transaction()
+ c = self.session.open_cursor(self.uri, None)
+ c[self.entries] = self.value
+ c.close()
+ self.session.timestamp_transaction(timestamp("read", base_ts + 0x200))
+ self.session.prepare_transaction(timestamp("prepare", base_ts + 0x201))
+ self.session.timestamp_transaction(timestamp("commit", base_ts + 0x202))
+ self.session.timestamp_transaction(timestamp("durable", base_ts + 0x203))
+ self.session.commit_transaction()
+
+ self.assertGreater(self.find_ts_log_rec(base_ts + 0x100), 0)
+ self.assertGreater(self.find_ts_log_rec(base_ts + 0x200), 0)
+ self.assertGreater(self.find_ts_log_rec(base_ts + 0x201), 0)
+ self.assertGreater(self.find_ts_log_rec(base_ts + 0x202), 0)
+ self.assertGreater(self.find_ts_log_rec(base_ts + 0x203), 0)
+
if __name__ == '__main__':
wttest.run()