Test Merge with timestamps in stress test (#10948)

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

Test Plan: make crash_test_with_ts

Reviewed By: ltamasi

Differential Revision: D41390854

Pulled By: riversand963

fbshipit-source-id: 599e114da8e2b2bbff5628fb8c67fa0393a31c05
main
Yanqin Jin 2 years ago committed by Facebook GitHub Bot
parent 8c0f5b1fcf
commit a8a4ed52a4
  1. 19
      db_stress_tool/db_stress_test_base.cc
  2. 9
      db_stress_tool/no_batched_ops_stress.cc

@ -517,9 +517,18 @@ void StressTest::PreloadDbAndReopenAsReadOnly(int64_t number_of_keys,
shared->Put(cf_idx, k, value_base, true /* pending */); shared->Put(cf_idx, k, value_base, true /* pending */);
std::string ts;
if (FLAGS_user_timestamp_size > 0) {
ts = GetNowNanos();
}
if (FLAGS_use_merge) { if (FLAGS_use_merge) {
if (!FLAGS_use_txn) { if (!FLAGS_use_txn) {
s = db_->Merge(write_opts, cfh, key, v); if (FLAGS_user_timestamp_size > 0) {
s = db_->Merge(write_opts, cfh, key, ts, v);
} else {
s = db_->Merge(write_opts, cfh, key, v);
}
} else { } else {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
Transaction* txn; Transaction* txn;
@ -538,7 +547,6 @@ void StressTest::PreloadDbAndReopenAsReadOnly(int64_t number_of_keys,
} else { } else {
if (!FLAGS_use_txn) { if (!FLAGS_use_txn) {
if (FLAGS_user_timestamp_size > 0) { if (FLAGS_user_timestamp_size > 0) {
const std::string ts = GetNowNanos();
s = db_->Put(write_opts, cfh, key, ts, v); s = db_->Put(write_opts, cfh, key, ts, v);
} else { } else {
s = db_->Put(write_opts, cfh, key, v); s = db_->Put(write_opts, cfh, key, v);
@ -2960,7 +2968,8 @@ void StressTest::MaybeUseOlderTimestampForRangeScan(ThreadState* thread,
ts_slice = ts_str; ts_slice = ts_str;
read_opts.timestamp = &ts_slice; read_opts.timestamp = &ts_slice;
if (!thread->rand.OneInOpt(3)) { // TODO (yanqin): support Merge with iter_start_ts
if (!thread->rand.OneInOpt(3) || FLAGS_use_merge || FLAGS_use_full_merge_v1) {
return; return;
} }
@ -2981,10 +2990,6 @@ void CheckAndSetOptionsForUserTimestamp(Options& options) {
static_cast<int>(cmp->timestamp_size())); static_cast<int>(cmp->timestamp_size()));
exit(1); exit(1);
} }
if (FLAGS_use_merge || FLAGS_use_full_merge_v1) {
fprintf(stderr, "Merge does not support timestamp yet.\n");
exit(1);
}
if (FLAGS_use_txn) { if (FLAGS_use_txn) {
fprintf(stderr, "TransactionDB does not support timestamp yet.\n"); fprintf(stderr, "TransactionDB does not support timestamp yet.\n");
exit(1); exit(1);

@ -61,7 +61,8 @@ class NonBatchedOpsStressTest : public StressTest {
static_cast<int>(VerificationMethod::kNumberOfMethods); static_cast<int>(VerificationMethod::kNumberOfMethods);
const VerificationMethod method = const VerificationMethod method =
static_cast<VerificationMethod>(thread->rand.Uniform(num_methods)); static_cast<VerificationMethod>(thread->rand.Uniform(
(FLAGS_user_timestamp_size > 0) ? num_methods - 1 : num_methods));
if (method == VerificationMethod::kIterator) { if (method == VerificationMethod::kIterator) {
std::unique_ptr<Iterator> iter( std::unique_ptr<Iterator> iter(
@ -805,7 +806,11 @@ class NonBatchedOpsStressTest : public StressTest {
if (FLAGS_use_merge) { if (FLAGS_use_merge) {
if (!FLAGS_use_txn) { if (!FLAGS_use_txn) {
s = db_->Merge(write_opts, cfh, k, v); if (FLAGS_user_timestamp_size == 0) {
s = db_->Merge(write_opts, cfh, k, v);
} else {
s = db_->Merge(write_opts, cfh, k, write_ts, v);
}
} else { } else {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
Transaction* txn; Transaction* txn;

Loading…
Cancel
Save