Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 07d46a8

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 f9f0741 commit 07d46a8

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
@@ -4152,11 +4152,14 @@ identify_locking_dependencies(ArchiveHandle *AH, TocEntry *te)
41524152
return;
41534153

41544154
/*
4155-
* We assume the item requires exclusive lock on each TABLE DATA item
4156-
* listed among its dependencies. (This was originally a dependency on
4157-
* the TABLE, but fix_dependencies repointed it to the data item. Note
4158-
* that all the entry types we are interested in here are POST_DATA, so
4159-
* they will all have been changed this way.)
4155+
* We assume the entry requires exclusive lock on each TABLE or TABLE DATA
4156+
* item listed among its dependencies. Originally all of these would have
4157+
* been TABLE items, but repoint_table_dependencies would have repointed
4158+
* them to the TABLE DATA items if those are present (which they might not
4159+
* be, eg in a schema-only dump). Note that all of the entries we are
4160+
* processing here are POST_DATA; otherwise there might be a significant
4161+
* difference between a dependency on a table and a dependency on its
4162+
* data, so that closer analysis would be needed here.
41604163
*/
41614164
lockids = (DumpId *) pg_malloc(te->nDeps * sizeof(DumpId));
41624165
nlockids = 0;
@@ -4165,7 +4168,8 @@ identify_locking_dependencies(ArchiveHandle *AH, TocEntry *te)
41654168
DumpId depid = te->dependencies[i];
41664169

41674170
if (depid <= AH->maxDumpId && AH->tocsByDumpId[depid] != NULL &&
4168-
strcmp(AH->tocsByDumpId[depid]->desc, "TABLE DATA") == 0)
4171+
((strcmp(AH->tocsByDumpId[depid]->desc, "TABLE DATA") == 0) ||
4172+
strcmp(AH->tocsByDumpId[depid]->desc, "TABLE") == 0))
41694173
lockids[nlockids++] = depid;
41704174
}
41714175

0 commit comments

Comments
 (0)