aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-08-28 19:46:59 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-08-28 19:46:59 -0400
commite0a0cc28d0829bea5d339fc2db6ac26ea13d5ab4 (patch)
tree17243aa2c2aa451cb4f3f88cb62aeda5e86a973d
parent8cff4f5348d075e063100071013f00a900c32b0f (diff)
downloadpostgresql-e0a0cc28d0829bea5d339fc2db6ac26ea13d5ab4.tar.gz
postgresql-e0a0cc28d0829bea5d339fc2db6ac26ea13d5ab4.zip
Make pg_restore's identify_locking_dependencies() more bulletproof.
This function had a blacklist of dump object types that it believed needed exclusive lock ... but we hadn't maintained that, so that it was missing ROW SECURITY, POLICY, and INDEX ATTACH items, all of which need (or should be treated as needing) exclusive lock. Since the same oversight seems likely in future, let's reverse the sense of the test so that the code has a whitelist of safe object types; better to wrongly assume a command can't be run in parallel than the opposite. Currently the only POST_DATA object type that's safe is CREATE INDEX ... and that list hasn't changed in a long time. Back-patch to 9.5 where RLS came in. Discussion: https://postgr.es/m/11450.1535483506@sss.pgh.pa.us
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 45a391bffb2..36e3383b851 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -4589,16 +4589,24 @@ identify_locking_dependencies(ArchiveHandle *AH, TocEntry *te)
int nlockids;
int i;
+ /*
+ * We only care about this for POST_DATA items. PRE_DATA items are not
+ * run in parallel, and DATA items are all independent by assumption.
+ */
+ if (te->section != SECTION_POST_DATA)
+ return;
+
/* Quick exit if no dependencies at all */
if (te->nDeps == 0)
return;
- /* Exit if this entry doesn't need exclusive lock on other objects */
- if (!(strcmp(te->desc, "CONSTRAINT") == 0 ||
- strcmp(te->desc, "CHECK CONSTRAINT") == 0 ||
- strcmp(te->desc, "FK CONSTRAINT") == 0 ||
- strcmp(te->desc, "RULE") == 0 ||
- strcmp(te->desc, "TRIGGER") == 0))
+ /*
+ * Most POST_DATA items are ALTER TABLEs or some moral equivalent of that,
+ * and hence require exclusive lock. However, we know that CREATE INDEX
+ * does not. (Maybe someday index-creating CONSTRAINTs will fall in that
+ * category too ... but today is not that day.)
+ */
+ if (strcmp(te->desc, "INDEX") == 0)
return;
/*