Skip to content

Commit a97c8c3

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 66e620d commit a97c8c3

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
@@ -4299,11 +4299,14 @@ identify_locking_dependencies(ArchiveHandle *AH, TocEntry *te)
42994299
return;
43004300

43014301
/*
4302-
* We assume the item requires exclusive lock on each TABLE DATA item
4303-
* listed among its dependencies. (This was originally a dependency on
4304-
* the TABLE, but fix_dependencies repointed it to the data item. Note
4305-
* that all the entry types we are interested in here are POST_DATA, so
4306-
* they will all have been changed this way.)
4302+
* We assume the entry requires exclusive lock on each TABLE or TABLE DATA
4303+
* item listed among its dependencies. Originally all of these would have
4304+
* been TABLE items, but repoint_table_dependencies would have repointed
4305+
* them to the TABLE DATA items if those are present (which they might not
4306+
* be, eg in a schema-only dump). Note that all of the entries we are
4307+
* processing here are POST_DATA; otherwise there might be a significant
4308+
* difference between a dependency on a table and a dependency on its
4309+
* data, so that closer analysis would be needed here.
43074310
*/
43084311
lockids = (DumpId *) pg_malloc(te->nDeps * sizeof(DumpId));
43094312
nlockids = 0;
@@ -4312,7 +4315,8 @@ identify_locking_dependencies(ArchiveHandle *AH, TocEntry *te)
43124315
DumpId depid = te->dependencies[i];
43134316

43144317
if (depid <= AH->maxDumpId && AH->tocsByDumpId[depid] != NULL &&
4315-
strcmp(AH->tocsByDumpId[depid]->desc, "TABLE DATA") == 0)
4318+
((strcmp(AH->tocsByDumpId[depid]->desc, "TABLE DATA") == 0) ||
4319+
strcmp(AH->tocsByDumpId[depid]->desc, "TABLE") == 0))
43164320
lockids[nlockids++] = depid;
43174321
}
43184322

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy