Merge pull request #4769 from citusdata/fix-4675

Populate DATABASEOID cache before CREATE INDEX CONCURRENTLY
pull/4767/head
Hadi Moshayedi 2021-03-03 13:04:41 -08:00 committed by GitHub
commit 6c409b5d3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -910,6 +910,19 @@ ExecuteDistributedDDLJob(DDLJob *ddlJob)
*/
if (ddlJob->startNewTransaction)
{
/*
* If cache is not populated, system catalog lookups will cause
* the xmin of current backend to change. Then the last phase
* of CREATE INDEX CONCURRENTLY, which is in a separate backend,
* will hang waiting for our backend and result in a deadlock.
*
* We populate the cache before starting the next transaction to
* avoid this. Most of the metadata has already been resolved in
* planning phase, we only need to lookup metadata needed for
* connection establishment.
*/
(void) CurrentDatabaseName();
CommitTransactionCommand();
StartTransactionCommand();
}