The following bug has been logged on the website:
Bug reference: 15026
Logged by: Mark Scheffer
Email address: pg2401k@pinkwin.com
PostgreSQL version: 10.1
Operating system: SLES 12 sp3
Description:
Following (fabricated) example shows there is a path in the GIST code that
leads to deadlocks:
-- Session 1:
DROP TABLE IF EXISTS locked;
CREATE TABLE locked
(
key text NOT NULL,
EXCLUDE USING gist (key WITH =)
);
BEGIN;
INSERT INTO locked(key) values('a');
-- Session 2:
INSERT INTO locked(key) values('a');
--> lock wait
-- Session 3:
INSERT INTO locked(key) values('a');
--> lock wait
-- Session 1:
ROLLBACK;
--> Session 3 generates deadlock:
ERROR: deadlock detected
DETAIL: Process 16079 waits for ShareLock on transaction 1420618256;
blocked by process 8594.
Process 8594 waits for ShareLock on transaction 1420618257; blocked by
process 16079.
HINT: See server log for query details.
CONTEXT: while checking exclusion constraint on tuple (0,2) in relation
"locked"
Note: Replacing the GIST with a unique index does not produce this error.
Note: Setting deadlock_timeout to some high value will help analysis.
Version: 10.1-9.1 from OpenSuse repository
"PostgreSQL 10.1 on x86_64-suse-linux-gnu, compiled by gcc (SUSE Linux)
4.8.5, 64-bit"
Regards,
Mark.