aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2014-09-26 11:21:35 -0400
committerRobert Haas <rhaas@postgresql.org>2014-09-26 11:36:25 -0400
commitd1844c21b0991bcc0824a411378b70e14ee531a4 (patch)
tree2a97e3ea9bc325473e33882f9de6be157c2d2bec /src
parentdc58d949245ca49eebf4c324d116159a4dfc2d6b (diff)
downloadpostgresql-d1844c21b0991bcc0824a411378b70e14ee531a4.tar.gz
postgresql-d1844c21b0991bcc0824a411378b70e14ee531a4.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index dce326ade4e..4bb28d528c7 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -4153,11 +4153,14 @@ identify_locking_dependencies(TocEntry *te)
return;
/*
- * We assume the item requires exclusive lock on each TABLE DATA item
- * listed among its dependencies. (This was originally a dependency on
- * the TABLE, but fix_dependencies repointed it to the data item. Note
- * that all the entry types we are interested in here are POST_DATA, so
- * they will all have been changed this way.)
+ * We assume the entry requires exclusive lock on each TABLE or TABLE DATA
+ * item listed among its dependencies. Originally all of these would have
+ * been TABLE items, but repoint_table_dependencies would have repointed
+ * them to the TABLE DATA items if those are present (which they might not
+ * be, eg in a schema-only dump). Note that all of the entries we are
+ * processing here are POST_DATA; otherwise there might be a significant
+ * difference between a dependency on a table and a dependency on its
+ * data, so that closer analysis would be needed here.
*/
lockids = (DumpId *) malloc(te->nDeps * sizeof(DumpId));
nlockids = 0;
@@ -4166,7 +4169,8 @@ identify_locking_dependencies(TocEntry *te)
DumpId depid = te->dependencies[i];
if (depid <= maxDumpId && tocsByDumpId[depid - 1] &&
- strcmp(tocsByDumpId[depid - 1]->desc, "TABLE DATA") == 0)
+ ((strcmp(tocsByDumpId[depid - 1]->desc, "TABLE DATA") == 0) ||
+ strcmp(tocsByDumpId[depid - 1]->desc, "TABLE") == 0))
lockids[nlockids++] = depid;
}