blob: 1b4dd43bf0ae03cce0e5e5443ca9318d68d6066d [file]
DROP TABLE IF EXISTS part_tbl;
DROP
CREATE TABLE part_tbl (a int, b int, c int) PARTITION BY RANGE(b) (START(1) END(2) EVERY(1));
CREATE
INSERT INTO part_tbl SELECT i, 1, i FROM generate_series(1,100)i;
INSERT 100
-- check gdd is enabled
show gp_enable_global_deadlock_detector;
gp_enable_global_deadlock_detector
------------------------------------
on
(1 row)
1:BEGIN;
BEGIN
1:DELETE FROM part_tbl_1_prt_1 WHERE c = segid(2,1);
DELETE 1
2:BEGIN;
BEGIN
2:DELETE FROM part_tbl WHERE c = segid(1,1);
DELETE 1
-- the below delete will wait to acquire the transaction lock to delete the tuple
-- held by Session 2
1&:DELETE FROM part_tbl_1_prt_1 WHERE c = segid(1,1); <waiting ...>
-- the below delete will wait to acquire the transaction lock to delete the tuple
-- held by Session 1
--
-- It is possible that GDD gets triggered immediately, so use '2>:' instead of
-- '2&:' for stable output.
2>:DELETE FROM part_tbl WHERE c = segid(2,1); <waiting ...>
1<: <... completed>
DELETE 1
2<: <... completed>
ERROR: canceling statement due to user request: "cancelled by global deadlock detector"
-- since gdd is on, Session 2 will be cancelled.
1:ROLLBACK;
ROLLBACK
2:ROLLBACK;
ROLLBACK
DROP TABLE IF EXISTS part_tbl;
DROP