Skip to content

Commit 5e0588c

Browse files
committed
[#28881] docdb: Fix PgRowLockTest.SelectForKeyShareWithRestart for enable txn ddl
Summary: Context: This test verifies that SELECT FOR KEY SHARE doesn't cause crashes during cluster restart(From D27662) Issue: With `ysql_yb_ddl_transaction_block_enabled` now enabled by default, the first test run `DROP TABLE` statement at the end is side the explicit user-defined transaction block (started for `SELECT FOR KEY SHARE`), which is not committed before the cluster restart. This prevents proper table cleanup, causing the second test run to fail with error: ``` 2025-10-09 02:50:35.764 UTC [547047] ERROR: relation "foo" already exists 2025-10-09 02:50:35.764 UTC [547047] STATEMENT: CREATE TABLE foo(k INT, v INT) ../../src/yb/yql/pgwrapper/pg_row_lock-test.cc:224: Failure Failed Bad status: Network error (yb/yql/pgwrapper/libpq_utils.cc:457): Execute of 'CREATE TABLE foo(k INT, v INT)' failed: 7, message: ERROR: relation "foo" already exists (pgsql error 42P07) (aux msg ERROR: relation "foo" already exists) ``` Fix: Use `DROP TABLE IF EXISTS` at the beginning, which maintains the test's original purpose of verifying SELECT FOR KEY SHARE doesn't cause crashes while also resolving the DDL transaction blocking issue by ensuring each run starts with a clean state, this avoids the `ERROR: relation "foo" already exists` test crash Jira: DB-18603 Test Plan: ./yb_build.sh --cxx-test pgwrapper_pg_row_lock-test --gtest_filter PgRowLockTest.SelectForKeyShareWithRestart Reviewers: bkolagani, rthallam Reviewed By: bkolagani, rthallam Subscribers: rthallam, ybase, yql Differential Revision: https://phorge.dev.yugabyte.com/D47354
1 parent 6b9242e commit 5e0588c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/yb/yql/pgwrapper/pg_row_lock-test.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,13 @@ TEST_F(PgRowLockTest, SelectForKeyShareWithRestart) {
222222
const auto table = "foo";
223223
auto conn = ASSERT_RESULT(Connect());
224224

225+
ASSERT_OK(conn.ExecuteFormat("DROP TABLE IF EXISTS $0", table));
225226
ASSERT_OK(conn.ExecuteFormat("CREATE TABLE $0(k INT, v INT)", table));
226227
ASSERT_OK(conn.ExecuteFormat("INSERT INTO $0 SELECT generate_series(1, 100), 1", table));
227228
ASSERT_OK(cluster_->FlushTablets());
228229

229230
ASSERT_OK(conn.StartTransaction(IsolationLevel::SNAPSHOT_ISOLATION));
230231
ASSERT_OK(conn.FetchFormat("SELECT * FROM $0 WHERE k=1 FOR KEY SHARE", table));
231-
232-
ASSERT_OK(conn.ExecuteFormat("DROP TABLE $0", table));
233232
});
234233
}
235234

0 commit comments

Comments
 (0)