diff --git a/db_stress_tool/db_stress_common.h b/db_stress_tool/db_stress_common.h index b66cce6df5..f4991a4a1f 100644 --- a/db_stress_tool/db_stress_common.h +++ b/db_stress_tool/db_stress_common.h @@ -161,6 +161,7 @@ DECLARE_int32(range_deletion_width); DECLARE_uint64(rate_limiter_bytes_per_sec); DECLARE_bool(rate_limit_bg_reads); DECLARE_bool(use_txn); +DECLARE_uint64(txn_write_policy); DECLARE_int32(backup_one_in); DECLARE_int32(checkpoint_one_in); DECLARE_int32(ingest_external_file_one_in); diff --git a/db_stress_tool/db_stress_gflags.cc b/db_stress_tool/db_stress_gflags.cc index 328426fb12..5036be4d52 100644 --- a/db_stress_tool/db_stress_gflags.cc +++ b/db_stress_tool/db_stress_gflags.cc @@ -371,6 +371,11 @@ DEFINE_bool(use_txn, false, "Use TransactionDB. Currently the default write policy is " "TxnDBWritePolicy::WRITE_PREPARED"); +DEFINE_uint64(txn_write_policy, 0, + "The transaction write policy. Default is " + "TxnDBWritePolicy::WRITE_COMMITTED. Note that this should not be " + "changed accross crashes."); + DEFINE_int32(backup_one_in, 0, "If non-zero, then CreateNewBackup() will be called once for " "every N operations on average. 0 indicates CreateNewBackup() " diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 07f3df74a8..dd0e3b27af 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -1671,8 +1671,9 @@ void StressTest::Open() { } else { #ifndef ROCKSDB_LITE TransactionDBOptions txn_db_options; - // For the moment it is sufficient to test WRITE_PREPARED policy - txn_db_options.write_policy = TxnDBWritePolicy::WRITE_PREPARED; + assert(FLAGS_txn_write_policy <= TxnDBWritePolicy::WRITE_UNPREPARED); + txn_db_options.write_policy = + static_cast(FLAGS_txn_write_policy); s = TransactionDB::Open(options_, txn_db_options, FLAGS_db, cf_descriptors, &column_families_, &txn_db_); db_ = txn_db_; diff --git a/include/rocksdb/utilities/transaction_db.h b/include/rocksdb/utilities/transaction_db.h index 91a9cec285..d286370fbb 100644 --- a/include/rocksdb/utilities/transaction_db.h +++ b/include/rocksdb/utilities/transaction_db.h @@ -25,9 +25,7 @@ class TransactionDBMutexFactory; enum TxnDBWritePolicy { WRITE_COMMITTED = 0, // write only the committed data - // TODO(myabandeh): Not implemented yet WRITE_PREPARED, // write data after the prepare phase of 2pc - // TODO(myabandeh): Not implemented yet WRITE_UNPREPARED // write data before the prepare phase of 2pc }; diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index e4bd145b1b..d96e02b8e7 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -159,6 +159,8 @@ cf_consistency_params = { txn_params = { "use_txn" : 1, + # Avoid lambda to set it once for the entire test + "txn_write_policy": random.randint(0, 2), "disable_wal": 0, # OpenReadOnly after checkpoint is not currnetly compatible with WritePrepared txns "checkpoint_one_in": 0,