]> granicus.if.org Git - postgresql/commit
Fix deadlock hazard in CREATE INDEX CONCURRENTLY
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 2 Jan 2018 22:16:16 +0000 (19:16 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 2 Jan 2018 22:16:16 +0000 (19:16 -0300)
commit54eff5311d7c8e3d309774713b91e78067d2ad42
tree00ed32e9835c67b252715b7488918732a41a6d2e
parent438036264a3b71eaf39b2d2eeca67237ed38ca51
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
c3d09b3bd23f 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 8aa3e47510b9 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
src/backend/commands/indexcmds.c
src/test/isolation/expected/multiple-cic.out [new file with mode: 0644]
src/test/isolation/isolation_schedule
src/test/isolation/specs/multiple-cic.spec [new file with mode: 0644]