From cf0fbb768658327223e885907492cde033a3c35b Mon Sep 17 00:00:00 2001 From: Hari Krishna Sunder Date: Tue, 15 Nov 2022 13:05:24 -0800 Subject: [PATCH] [#15026] Minor refactoring of xcluster consistency computation Summary: Using a single line statement when computing use_xcluster_database_consistency. Replacing ASSERT_RESULT with ASSERT_OK in xcluster_safe_time-itest as result output is not read. Test Plan: xcluster_safe_time-itest Reviewers: rahuldesirazu, slingam, dmitry Reviewed By: dmitry Subscribers: ybase Differential Revision: https://phabricator.dev.yugabyte.com/D21130 --- .../yb/integration-tests/xcluster_safe_time-itest.cc | 8 +++----- src/yb/yql/pggate/pg_session.cc | 10 +++------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ent/src/yb/integration-tests/xcluster_safe_time-itest.cc b/ent/src/yb/integration-tests/xcluster_safe_time-itest.cc index cae265052c39..fc5938035523 100644 --- a/ent/src/yb/integration-tests/xcluster_safe_time-itest.cc +++ b/ent/src/yb/integration-tests/xcluster_safe_time-itest.cc @@ -735,17 +735,15 @@ TEST_F_EX(XClusterConsistencyTest, LoginWithNoSafeTime, XClusterConsistencyNoSaf // Verify that we can login and query a catalog table. auto conn = ASSERT_RESULT(consumer_cluster_.ConnectToDB( consumer_table1_->name().namespace_name(), true /*simple_query_protocol*/)); - - auto result = ASSERT_RESULT(conn.Fetch("SELECT relname FROM pg_catalog.pg_class LIMIT 1;")); + ASSERT_OK(conn.Fetch("SELECT relname FROM pg_catalog.pg_class LIMIT 1")); // Verify that we can't read user table with default consistency. const auto query = Format("SELECT * FROM $0", GetCompleteTableName(consumer_table1_->name())); - ASSERT_NOK(conn.Execute(query)); - // Verify that we can't read user table with tablet level consistency. + // Verify that we can read user table with tablet level consistency. ASSERT_OK(conn.Execute("SET yb_xcluster_consistency_level = tablet")); - result = ASSERT_RESULT(conn.Fetch(query)); + ASSERT_OK(conn.Fetch(query)); } } // namespace enterprise diff --git a/src/yb/yql/pggate/pg_session.cc b/src/yb/yql/pggate/pg_session.cc index e80e90ca4e8a..072c616d039e 100644 --- a/src/yb/yql/pggate/pg_session.cc +++ b/src/yb/yql/pggate/pg_session.cc @@ -538,13 +538,9 @@ Result PgSession::Perform( } options.set_force_global_transaction(global_transaction); - auto use_xcluster_database_consistency = - yb_xcluster_consistency_level == XCLUSTER_CONSISTENCY_DATABASE; - if (use_catalog_session || pg_txn_manager_->IsDdlMode()) { - // For Catalog sessions and DDLs we always want to read our universe's latest data. - use_xcluster_database_consistency = false; - } - options.set_use_xcluster_database_consistency(use_xcluster_database_consistency); + options.set_use_xcluster_database_consistency( + yb_xcluster_consistency_level == XCLUSTER_CONSISTENCY_DATABASE && + !(use_catalog_session || pg_txn_manager_->IsDdlMode())); auto promise = std::make_shared>();