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_

<table>
  <tr>
    <th>TestGet thread</th>
    <th> A writing thread</th>
  </tr>
  <tr>
    <td>read_opts.timestamp = GetNow()</td>
    <td></td>
  </tr>
  <tr>
    <td></td>
    <td>Lock key, do write</td>
  </tr>
  <tr>
    <td>Lock key, read(read_opts) return NotFound</td>
    <td></td>
  </tr>
</table>

Pull Request resolved: https://github.com/facebook/rocksdb/pull/12222

Reviewed By: jowlyzhang

Differential Revision: D52678830

Pulled By: jaykorean

fbshipit-source-id: 6e154f67bb32968add8fea0b7ae7c4858ea64ee7
This commit is contained in:
Jay Huh 2024-01-10 16:35:54 -08:00 committed by Facebook GitHub Bot
parent 513aae1a31
commit 0758271d51
1 changed files with 12 additions and 1 deletions

View File

@ -910,6 +910,17 @@ class NonBatchedOpsStressTest : public StressTest {
PinnableWideColumns from_db; 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); const Status s = db_->GetEntity(read_opts, cfh, key, &from_db);
int error_count = 0; int error_count = 0;
@ -956,7 +967,7 @@ class NonBatchedOpsStressTest : public StressTest {
} else if (s.IsNotFound()) { } else if (s.IsNotFound()) {
thread->stats.AddGets(1, 0); thread->stats.AddGets(1, 0);
if (!FLAGS_skip_verifydb) { if (!FLAGS_skip_verifydb && !read_older_ts) {
ExpectedValue expected = ExpectedValue expected =
shared->Get(rand_column_families[0], rand_keys[0]); shared->Get(rand_column_families[0], rand_keys[0]);
if (ExpectedValueHelper::MustHaveExisted(expected, expected)) { if (ExpectedValueHelper::MustHaveExisted(expected, expected)) {