Skip to content

Commit d54f99e

Browse files
committed
Fix rare deadlock failure in create_am regression test.
The "DROP ACCESS METHOD gist2" test will require locking the index to be dropped and then its table; while most ordinary operations lock a table first then its index. While no concurrent test scripts should be touching fast_emp4000, autovacuum might chance to be processing that table when the DROP runs, resulting in a deadlock failure. This is pretty rare but we see it in the buildfarm from time to time. To fix, acquire a lock on fast_emp4000 before issuing the DROP. Since the point of the exercise is mostly to prevent buildfarm failures, back-patch to 9.6 where this test was introduced. Discussion: https://postgr.es/m/839004.1599185607@sss.pgh.pa.us
1 parent 49d7165 commit d54f99e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/test/regress/expected/create_am.out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,13 @@ ERROR: cannot drop access method gist2 because other objects depend on it
102102
DETAIL: index grect2ind2 depends on operator class box_ops for access method gist2
103103
HINT: Use DROP ... CASCADE to drop the dependent objects too.
104104
-- Drop access method cascade
105+
-- To prevent a (rare) deadlock against autovacuum,
106+
-- we must lock the table that owns the index that will be dropped
107+
BEGIN;
108+
LOCK TABLE fast_emp4000;
105109
DROP ACCESS METHOD gist2 CASCADE;
106110
NOTICE: drop cascades to index grect2ind2
111+
COMMIT;
107112
--
108113
-- Test table access methods
109114
--

src/test/regress/sql/create_am.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ ROLLBACK;
7070
DROP ACCESS METHOD gist2;
7171

7272
-- Drop access method cascade
73+
-- To prevent a (rare) deadlock against autovacuum,
74+
-- we must lock the table that owns the index that will be dropped
75+
BEGIN;
76+
LOCK TABLE fast_emp4000;
7377
DROP ACCESS METHOD gist2 CASCADE;
78+
COMMIT;
7479

7580

7681
--

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy