postgresql/src/backend/commands
Alvaro Herrera 54eff5311d Fix deadlock hazard in CREATE INDEX CONCURRENTLY
Multiple sessions doing CREATE INDEX CONCURRENTLY simultaneously are
supposed to be able to work in parallel, as evidenced by fixes in commit
c3d09b3bd2 specifically to support this case.  In reality, one of the
sessions would be aborted by a misterious "deadlock detected" error.

Jeff Janes diagnosed that this is because of leftover snapshots used for
system catalog scans -- this was broken by 8aa3e47510 keeping track of
(registering) the catalog snapshot.  To fix the deadlocks, it's enough
to de-register that snapshot prior to waiting.

Backpatch to 9.4, which introduced MVCC catalog scans.

Include an isolationtester spec that 8 out of 10 times reproduces the
deadlock with the unpatched code for me (Álvaro).

Author: Jeff Janes
Diagnosed-by: Jeff Janes
Reported-by: Jeremy Finzel
Discussion: https://postgr.es/m/CAMa1XUhHjCv8Qkx0WOr1Mpm_R4qxN26EibwCrj0Oor2YBUFUTg%40mail.gmail.com
2018-01-02 19:16:16 -03:00
..
Makefile Implement multivariate n-distinct coefficients 2017-03-24 14:06:10 -03:00
aggregatecmds.c SQL procedures 2017-11-30 11:03:20 -05:00
alter.c SQL procedures 2017-11-30 11:03:20 -05:00
amcmds.c Fix typos in comments. 2017-02-06 11:33:58 +02:00
analyze.c When VACUUM or ANALYZE skips a concurrently dropped table, log it. 2017-12-04 15:25:55 -05:00
async.c Replace remaining uses of pq_sendint with pq_sendint{8,16,32}. 2017-10-11 21:00:46 -07:00
cluster.c Update relation's stats in pg_class during vacuum full. 2017-12-27 18:25:37 +03:00
collationcmds.c Don't install ICU collation keyword variants 2017-08-21 19:21:07 -04:00
comment.c Add some const decorations to prototypes 2017-11-10 13:38:57 -05:00
constraint.c Allow index AMs to cache data across aminsert calls within a SQL command. 2017-02-09 11:52:12 -05:00
conversioncmds.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
copy.c Apply identity sequence values on COPY 2017-12-08 09:18:18 -05:00
createas.c Allow DML commands that create tables to use parallel query. 2017-10-05 11:40:48 -04:00
dbcommands.c Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
define.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
discard.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
dropcmds.c SQL procedures 2017-11-30 11:03:20 -05:00
event_trigger.c SQL procedures 2017-11-30 11:03:20 -05:00
explain.c Fix EXPLAIN ANALYZE output for Parallel Hash. 2018-01-01 14:38:23 -08:00
extension.c Add some const decorations to prototypes 2017-11-10 13:38:57 -05:00
foreigncmds.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
functioncmds.c SQL procedures 2017-11-30 11:03:20 -05:00
indexcmds.c Fix deadlock hazard in CREATE INDEX CONCURRENTLY 2018-01-02 19:16:16 -03:00
lockcmds.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
matview.c Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
opclasscmds.c SQL procedures 2017-11-30 11:03:20 -05:00
operatorcmds.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
policy.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
portalcmds.c Remove unnecessary PG_TRY overhead for CurrentResourceOwner changes. 2017-10-11 17:44:09 -04:00
prepare.c Rearrange execution of PARAM_EXTERN Params for plpgsql's benefit. 2017-12-21 12:57:45 -05:00
proclang.c Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
publicationcmds.c Message style fixes 2017-09-11 11:21:27 -04:00
schemacmds.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
seclabel.c Reduce excessive dereferencing of function pointers 2017-09-07 13:56:09 -04:00
sequence.c Remove unnecessary PG_TRY overhead for CurrentResourceOwner changes. 2017-10-11 17:44:09 -04:00
statscmds.c Message style fixes 2017-09-11 11:21:27 -04:00
subscriptioncmds.c Rethink MemoryContext creation to improve performance. 2017-12-13 13:55:16 -05:00
tablecmds.c Fix assorted syscache lookup sloppiness in partition-related code. 2017-11-27 19:22:08 -05:00
tablespace.c Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
trigger.c Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
tsearchcmds.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
typecmds.c Add some const decorations to prototypes 2017-11-10 13:38:57 -05:00
user.c Don't allow logging in with empty password. 2017-08-07 17:03:42 +03:00
vacuum.c Extend near-wraparound hints to include replication slots 2017-12-29 14:01:25 +00:00
vacuumlazy.c Perform a lot more sanity checks when freezing tuples. 2017-12-14 18:20:47 -08:00
variable.c Remove uses of "slave" in replication contexts 2017-08-10 22:55:41 -04:00
view.c Add some const decorations to prototypes 2017-11-10 13:38:57 -05:00