Skip to content

Commit d1844c2

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 dc58d94 commit d1844c2

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
@@ -4153,11 +4153,14 @@ identify_locking_dependencies(TocEntry *te)
41534153
return;
41544154

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

41684171
if (depid <= maxDumpId && tocsByDumpId[depid - 1] &&
4169-
strcmp(tocsByDumpId[depid - 1]->desc, "TABLE DATA") == 0)
4172+
((strcmp(tocsByDumpId[depid - 1]->desc, "TABLE DATA") == 0) ||
4173+
strcmp(tocsByDumpId[depid - 1]->desc, "TABLE") == 0))
41704174
lockids[nlockids++] = depid;
41714175
}
41724176

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