c3d09b3bd23f5f6 fixed it so concurrent CIC would not deadlock (or at least
not as reliably as before) by dropping its own snapshot before waiting for
all the other ones to go away.

With commit 8aa3e47510b969354ea02a, concurrent CREATE INDEX CONCURRENTLY on
different tables in the same database started deadlocking against each
other again quite reliably.

I think the solution is simply to drop the catalog snapshot as well, as in
the attached.

reported by Jeremy Finzel here:
https://www.postgresql.org/message-id/flat/CAMa1XUhHjCv8Qkx0WOr1Mpm_R4qxN26EibwCrj0Oor2YBUFUTg%40mail.gmail.com#cama1xuhhjcv8qkx0wor1mpm_r4qxn26eibwcrj0oor2ybuf...@mail.gmail.com


Cheers,

Jeff
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 97091dd..d4ac2e1 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -861,6 +861,7 @@ DefineIndex(Oid relationId,
 
 	PopActiveSnapshot();
 	UnregisterSnapshot(snapshot);
+	InvalidateCatalogSnapshotConditionally();
 
 	/*
 	 * The index is now valid in the sense that it contains all currently

Reply via email to