Populate DATABASEOID cache before CREATE INDEX CONCURRENTLY

pull/4769/head
Hadi Moshayedi 2021-03-02 15:58:06 -08:00
parent fc493547cd
commit affe38eac6
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();
}