blob: 15d9a48c71ad10d959de1f880d13646b92aefe16 [file] [log] [blame]
-- This test is used to test if waiting on a resource queue lock will
-- trigger a local deadlock detection.
0: CREATE RESOURCE QUEUE rq_deadlock_test WITH (active_statements = 1);
CREATE
0: CREATE role role_deadlock_test RESOURCE QUEUE rq_deadlock_test;
CREATE
0: SELECT gp_inject_fault_infinite('before_auto_stats', 'suspend', dbid) FROM gp_segment_configuration WHERE content = -1 AND role = 'p';
gp_inject_fault_infinite
--------------------------
Success:
(1 row)
0&: SELECT gp_wait_until_triggered_fault('before_auto_stats', 1, dbid) FROM gp_segment_configuration WHERE content = -1 AND role = 'p'; <waiting ...>
1: SET role role_deadlock_test;
SET
-- We need gp_autostats_mode to be ON_NO_STATS in this test.
1: SET gp_autostats_mode = ON_NO_STATS;
SET
1: SHOW gp_autostats_mode;
gp_autostats_mode
-------------------
on_no_stats
(1 row)
1: CREATE TABLE t_deadlock_test(c1 int);
CREATE
1&: INSERT INTO t_deadlock_test VALUES (1); <waiting ...>
2: SET role role_deadlock_test;
SET
2: BEGIN;
BEGIN
2: analyze t_deadlock_test;
ANALYZE
0<: <... completed>
gp_wait_until_triggered_fault
-------------------------------
Success:
(1 row)
0: select gp_inject_fault_infinite('before_auto_stats', 'reset', dbid) from gp_segment_configuration where content = -1 and role = 'p';
gp_inject_fault_infinite
--------------------------
Success:
(1 row)
2: SELECT * FROM t_deadlock_test;
ERROR: deadlock detected
DETAIL: Process 1618 waits for ExclusiveLock on resource queue 16520; blocked by process 1606.
Process 1606 waits for ShareUpdateExclusiveLock on relation 16522 of database 16478; blocked by process 1618.
HINT: See server log for query details.
2: ROLLBACK;
ROLLBACK
1<: <... completed>
INSERT 1
-- Sanity check: Ensure that the resource queue is now empty.
0: SELECT rsqcountlimit, rsqcountvalue from pg_resqueue_status WHERE rsqname = 'rq_deadlock_test';
rsqcountlimit | rsqcountvalue
---------------+---------------
1 | 0
(1 row)
-- Clean up the test
0: DROP TABLE t_deadlock_test;
DROP
0: DROP ROLE role_deadlock_test;
DROP
0: DROP RESOURCE QUEUE rq_deadlock_test;
DROP