diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgPessimisticLockingRegress.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgPessimisticLockingRegress.java index 3f13a73bdb7c..e287446dc2da 100644 --- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgPessimisticLockingRegress.java +++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgPessimisticLockingRegress.java @@ -26,9 +26,10 @@ public class TestPgPessimisticLockingRegress extends BasePgSQLTest { @Override protected Map getTServerFlags() { Map flagMap = super.getTServerFlags(); - flagMap.put("enable_pessimistic_locking", "true"); + flagMap.put("enable_wait_queue_based_pessimistic_locking", "true"); flagMap.put("enable_deadlock_detection", "true"); flagMap.put("yb_enable_read_committed_isolation", "false"); + flagMap.put("auto_promote_nonlocal_transactions_to_global", "false"); return flagMap; } diff --git a/src/yb/client/transaction.cc b/src/yb/client/transaction.cc index 59752fa3582e..9d054618dc71 100644 --- a/src/yb/client/transaction.cc +++ b/src/yb/client/transaction.cc @@ -72,9 +72,6 @@ DEFINE_uint64(transaction_heartbeat_usec, 500000 * yb::kTimeMultiplier, DEFINE_bool(transaction_disable_heartbeat_in_tests, false, "Disable heartbeat during test."); DECLARE_uint64(max_clock_skew_usec); -DEFINE_bool(auto_promote_nonlocal_transactions_to_global, true, - "Automatically promote transactions touching data outside of region to global."); - DEFINE_test_flag(int32, transaction_inject_flushed_delay_ms, 0, "Inject delay before processing flushed operations by transaction."); @@ -93,6 +90,8 @@ METRIC_DEFINE_counter(server, transaction_promotions, yb::MetricUnit::kTransactions, "Number of transactions being promoted to global transactions"); +DECLARE_bool(auto_promote_nonlocal_transactions_to_global); + namespace yb { namespace client { diff --git a/src/yb/common/common_flags.cc b/src/yb/common/common_flags.cc index 6f08cc81c76f..41b90e3cf98d 100644 --- a/src/yb/common/common_flags.cc +++ b/src/yb/common/common_flags.cc @@ -58,6 +58,9 @@ DEFINE_bool(enable_deadlock_detection, false, "If true, enables distributed dead TAG_FLAG(enable_deadlock_detection, advanced); TAG_FLAG(enable_deadlock_detection, evolving); +DEFINE_bool(auto_promote_nonlocal_transactions_to_global, true, + "Automatically promote transactions touching data outside of region to global."); + DEFINE_test_flag(bool, enable_db_catalog_version_mode, false, "Enable the per database catalog version mode, a DDL statement is assumed to " "only affect the current database and will only increment catalog version for " diff --git a/src/yb/tserver/ts_tablet_manager.cc b/src/yb/tserver/ts_tablet_manager.cc index 71f4e53bc5f5..35a85ca48615 100644 --- a/src/yb/tserver/ts_tablet_manager.cc +++ b/src/yb/tserver/ts_tablet_manager.cc @@ -235,10 +235,12 @@ DEFINE_test_flag(int32, sleep_after_tombstoning_tablet_secs, 0, DEFINE_bool(enable_restart_transaction_status_tablets_first, true, "Set to true to prioritize bootstrapping transaction status tablets first."); -DEFINE_bool(enable_pessimistic_locking, false, +DEFINE_bool(enable_wait_queue_based_pessimistic_locking, false, "If true, use pessimistic locking behavior in conflict resolution."); -TAG_FLAG(enable_pessimistic_locking, evolving); -TAG_FLAG(enable_pessimistic_locking, hidden); +TAG_FLAG(enable_wait_queue_based_pessimistic_locking, evolving); +TAG_FLAG(enable_wait_queue_based_pessimistic_locking, hidden); + +DECLARE_bool(auto_promote_nonlocal_transactions_to_global); DECLARE_string(rocksdb_compact_flush_rate_limit_sharing_mode); @@ -487,9 +489,15 @@ Status TSTabletManager::Init() { &server_->proxy_cache(), local_peer_pb_.cloud_info()); - if (FLAGS_enable_pessimistic_locking) { - waiting_txn_registry_ = std::make_unique( - client_future(), scoped_refptr(server_->clock())); + if (FLAGS_enable_wait_queue_based_pessimistic_locking) { + if (FLAGS_auto_promote_nonlocal_transactions_to_global) { + LOG(WARNING) << "Ignoring enable_wait_queue_based_pessimistic_locking=true since " + << "auto_promote_nonlocal_transactions_to_global is enabled. These two features " + << "are not yet supported together."; + } else { + waiting_txn_registry_ = std::make_unique( + client_future(), scoped_refptr(server_->clock())); + } } deque metas; diff --git a/src/yb/yql/pgwrapper/pg_pessimistic_locking-test.cc b/src/yb/yql/pgwrapper/pg_pessimistic_locking-test.cc index 017c3275b184..e6356e8f9761 100644 --- a/src/yb/yql/pgwrapper/pg_pessimistic_locking-test.cc +++ b/src/yb/yql/pgwrapper/pg_pessimistic_locking-test.cc @@ -38,13 +38,14 @@ #include "yb/util/pb_util.h" -DECLARE_bool(enable_pessimistic_locking); +DECLARE_bool(enable_wait_queue_based_pessimistic_locking); DECLARE_bool(enable_deadlock_detection); DECLARE_bool(TEST_select_all_status_tablets); DECLARE_string(ysql_pg_conf_csv); DECLARE_bool(enable_automatic_tablet_splitting); DECLARE_int32(cleanup_split_tablets_interval_sec); DECLARE_uint64(rpc_connection_timeout_ms); +DECLARE_bool(auto_promote_nonlocal_transactions_to_global); using namespace std::literals; @@ -58,9 +59,10 @@ class PgPessimisticLockingTest : public PgMiniTestBase { void SetUp() override { FLAGS_ysql_pg_conf_csv = Format( "statement_timeout=$0", kClientStatementTimeoutSeconds * 1ms / 1s); - FLAGS_enable_pessimistic_locking = true; + FLAGS_enable_wait_queue_based_pessimistic_locking = true; FLAGS_enable_deadlock_detection = true; FLAGS_TEST_select_all_status_tablets = true; + FLAGS_auto_promote_nonlocal_transactions_to_global = false; PgMiniTestBase::SetUp(); } @@ -665,9 +667,10 @@ class PgTabletSplittingPessimisticLockingTest : public PgTabletSplitTestBase, protected: void SetUp() override { FLAGS_rpc_connection_timeout_ms = 60000; - FLAGS_enable_pessimistic_locking = true; + FLAGS_enable_wait_queue_based_pessimistic_locking = true; FLAGS_enable_deadlock_detection = true; FLAGS_enable_automatic_tablet_splitting = false; + FLAGS_auto_promote_nonlocal_transactions_to_global = false; PgTabletSplitTestBase::SetUp(); }