Skip to content

Commit

Permalink
[#15026] Minor refactoring of xcluster consistency computation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hari90 committed Nov 16, 2022
1 parent 47dec92 commit cf0fbb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
8 changes: 3 additions & 5 deletions ent/src/yb/integration-tests/xcluster_safe_time-itest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions src/yb/yql/pggate/pg_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,9 @@ Result<PerformFuture> 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<std::promise<PerformResult>>();

Expand Down

0 comments on commit cf0fbb7

Please sign in to comment.