From 0758271d519bcc5d7266fec26ae1f3ab887aa130 Mon Sep 17 00:00:00 2001 From: Jay Huh Date: Wed, 10 Jan 2024 16:35:54 -0800 Subject: [PATCH] Fix TestGetEntity in stress test when UDT is enabled (#12222) Summary: Similar to https://github.com/facebook/rocksdb/issues/11249 , we started to get failures from `TestGetEntity` when the User-defined-timestamp was enabled. Applying the same fix as the `TestGet` _Scenario copied from #11249_
TestGet thread A writing thread
read_opts.timestamp = GetNow()
Lock key, do write
Lock key, read(read_opts) return NotFound
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12222 Reviewed By: jowlyzhang Differential Revision: D52678830 Pulled By: jaykorean fbshipit-source-id: 6e154f67bb32968add8fea0b7ae7c4858ea64ee7 --- db_stress_tool/no_batched_ops_stress.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/db_stress_tool/no_batched_ops_stress.cc b/db_stress_tool/no_batched_ops_stress.cc index eb5b3b2f90..c5e64b8620 100644 --- a/db_stress_tool/no_batched_ops_stress.cc +++ b/db_stress_tool/no_batched_ops_stress.cc @@ -910,6 +910,17 @@ class NonBatchedOpsStressTest : public StressTest { PinnableWideColumns from_db; + ReadOptions read_opts_copy = read_opts; + std::string read_ts_str; + Slice read_ts_slice; + if (FLAGS_user_timestamp_size > 0) { + read_ts_str = GetNowNanos(); + read_ts_slice = read_ts_str; + read_opts_copy.timestamp = &read_ts_slice; + } + bool read_older_ts = MaybeUseOlderTimestampForPointLookup( + thread, read_ts_str, read_ts_slice, read_opts_copy); + const Status s = db_->GetEntity(read_opts, cfh, key, &from_db); int error_count = 0; @@ -956,7 +967,7 @@ class NonBatchedOpsStressTest : public StressTest { } else if (s.IsNotFound()) { thread->stats.AddGets(1, 0); - if (!FLAGS_skip_verifydb) { + if (!FLAGS_skip_verifydb && !read_older_ts) { ExpectedValue expected = shared->Get(rand_column_families[0], rand_keys[0]); if (ExpectedValueHelper::MustHaveExisted(expected, expected)) {