8000 Fix identify_locking_dependencies for schema-only dumps. · zyfran/postgres@d72ecc9 · GitHub
[go: up one dir, main page]

Skip to content

Commit d72ecc9

Browse files
committed
Fix identify_locking_dependencies for schema-only dumps.
Without this fix, parallel restore of a schema-only dump can deadlock, because when the dump is schema-only, the dependency will still be pointing at the TABLE item rather than the TABLE DATA item. Robert Haas and Tom Lane
1 parent a8acf4d commit d72ecc9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,11 +4070,14 @@ identify_locking_dependencies(ArchiveHandle *AH, TocEntry *te)
40704070
return;
40714071

40724072
/*
4073-
* We assume the item requires exclusive lock on each TABLE DATA item
4074-
* listed among its dependencies. (This was originally a dependency on
4075-
* the TABLE, but fix_dependencies repointed it to the data item. Note
4076-
* that all the entry types we are interested in here are POST_DATA, so
4077-
* they will all have been changed this way.)
4073+
* We assume the entry requires exclusive lock on each TABLE or TABLE DATA
4074+
* item listed among its dependencies. Originally all of these would have
4075+
* been TABLE items, but repoint_table_dependencies would have repointed
4076+
* them to the TABLE DATA items if those are present (which they might not
4077+
* be, eg in a schema-only dump). Note that all of the entries we are
4078+
* processing here are POST_DATA; otherwise there might be a significant
4079+
* difference between a dependency on a table and a dependency on its
4080+
* data, so that closer analysis would be needed here.
40784081
*/
40794082
lockids = (DumpId *) pg_malloc(te->nDeps * sizeof(DumpId));
40804083
nlockids = 0;
@@ -4083,7 +4086,8 @@ identify_locking_dependencies(ArchiveHandle *AH, TocEntry *te)
40834086
DumpId depid = te->dependencies[i];
40844087

40854088
if (depid <= AH->maxDumpId && AH->tocsByDumpId[depid] != NULL &&
4086-
strcmp(AH->tocsByDumpId[depid]->desc, "TABLE DATA") == 0)< 557D /div>
4089+
((strcmp(AH->tocsByDumpId[depid]->desc, "TABLE DATA") == 0) ||
4090+
strcmp(AH->tocsByDumpId[depid]->desc, "TABLE") == 0))
40874091
lockids[nlockids++] = depid;
40884092
}
40894093

0 commit comments

Comments
 (0)
0