Skip to content

Commit aece9ea

Browse files
committed
fk_read_committed: set explicit lock wait timeouts
Previously, we enabled locking for serializable inserts in this test without setting a lock timeout. In the event that the pg_sleep() in these race tests completes and the UPDATE/DELETE gets locks before the INSERT runs, the INSERT will wait indefinitely for the locks because the lock_timeout defaults to 0 (no timeout). Because the test itself is waiting for the INSERT to finish, the deadlock between the INSERT and the UPDATE/DELETE is never detected, resulting in the test timing out after a long wait. This change doesn't prevent the test from failing, but should make what is going on a little more obvious. If the test is failing with any regularity, we should increase the pg_sleep() time, but so far this seems like a rarity. Informs: #153453 Release note: None
1 parent cdb61d6 commit aece9ea

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pkg/ccl/logictestccl/testdata/logic_test/fk_read_committed

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ statement ok
135135
SELECT 1;
136136

137137
statement async fk_delete
138-
WITH sleep AS (SELECT pg_sleep(1)) DELETE FROM parent_150282@parent_150282_i_idx WHERE i = 2;
138+
WITH sleep AS (SELECT pg_sleep(2)) DELETE FROM parent_150282@parent_150282_i_idx WHERE i = 2;
139139

140140
user testuser
141141

142142
statement ok
143+
SET lock_timeout = '10s';
143144
SET enable_implicit_fk_locking_for_serializable = on;
144145
SET enable_shared_locking_for_serializable = on;
145146
SET enable_durable_locking_for_serializable = on;
@@ -174,11 +175,12 @@ statement ok
174175
SELECT 1;
175176

176177
statement async fk_update
177-
WITH sleep AS (SELECT pg_sleep(1)) UPDATE parent_150282 SET p = 4 WHERE i = 2;
178+
WITH sleep AS (SELECT pg_sleep(2)) UPDATE parent_150282 SET p = 4 WHERE i = 2;
178179

179180
user testuser
180181

181182
statement ok
183+
SET lock_timeout = '10s';
182184
SET enable_implicit_fk_locking_for_serializable = on;
183185
SET enable_shared_locking_for_serializable = on;
184186
SET enable_durable_locking_for_serializable = on;
@@ -220,11 +222,12 @@ statement ok
220222
SELECT 1;
221223

222224
statement async fk_delete
223-
WITH sleep AS (SELECT pg_sleep(1)) DELETE FROM parent_150282 WHERE p = 1;
225+
WITH sleep AS (SELECT pg_sleep(2)) DELETE FROM parent_150282 WHERE p = 1;
224226

225227
user testuser
226228

227229
statement ok
230+
SET lock_timeout = '10s';
228231
SET enable_implicit_fk_locking_for_serializable = on;
229232
SET enable_shared_locking_for_serializable = on;
230233
SET enable_durable_locking_for_serializable = on;
@@ -248,6 +251,7 @@ SELECT * FROM child_150282;
248251
user testuser
249252

250253
statement ok
254+
RESET lock_timeout;
251255
RESET enable_implicit_fk_locking_for_serializable;
252256
RESET enable_shared_locking_for_serializable;
253257
RESET enable_durable_locking_for_serializable
@@ -373,7 +377,7 @@ user root
373377

374378
# Give the delete a moment to wait on the p=3 lock by testuser2.
375379
statement ok
376-
SELECT pg_sleep(1)
380+
SELECT pg_sleep(2)
377381

378382
# The serializable insert needs this locking to properly sychronize with the
379383
# read committed delete.
@@ -392,7 +396,7 @@ user testuser
392396

393397
# Give the insert a moment to wait on the p=2 update by testuser.
394398
statement ok
395-
SELECT pg_sleep(1)
399+
SELECT pg_sleep(2)
396400

397401
statement ok
398402
ROLLBACK
@@ -401,7 +405,7 @@ user testuser2
401405

402406
# Give the insert a moment to lock p=1.
403407
statement ok
404-
SELECT pg_sleep(1)
408+
SELECT pg_sleep(2)
405409

406410
statement ok
407411
ROLLBACK

0 commit comments

Comments
 (0)