diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-06-17 18:19:21 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-06-17 18:19:21 -0400 |
commit | 32e5768390fe7c10230a1d02d9ee026461a609a9 (patch) | |
tree | 02c29d9f0abaaa8a3272274a8211aab1601b8f4c /src | |
parent | f49b2eab23199229a322745b6480692056070301 (diff) | |
download | postgresql-32e5768390fe7c10230a1d02d9ee026461a609a9.tar.gz postgresql-32e5768390fe7c10230a1d02d9ee026461a609a9.zip |
Obtain table locks as soon as practical during pg_dump.
For some reason, when we (I) added table lock acquisition to pg_dump,
we didn't think about making it happen as soon as possible after the
start of the transaction. What with subsequent additions, there was
actually quite a lot going on before we got around to that; which sort
of defeats the purpose. Rearrange the order of calls in dumpSchema()
to close the risk window as much as we easily can. Back-patch to all
supported branches.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_dump/common.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 789638fec45..7ab6ce889a7 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -113,6 +113,17 @@ getSchemaData(int *numTablesPtr) write_msg(NULL, "reading schemas\n"); nsinfo = getNamespaces(&numNamespaces); + /* + * getTables should be done as soon as possible, so as to minimize the + * window between starting our transaction and acquiring per-table locks. + * However, we have to do getNamespaces first because the tables get + * linked to their containing namespaces during getTables. + */ + if (g_verbose) + write_msg(NULL, "reading user-defined tables\n"); + tblinfo = getTables(&numTables); + tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo)); + if (g_verbose) write_msg(NULL, "reading user-defined functions\n"); funinfo = getFuncs(&numFuncs); @@ -175,11 +186,6 @@ getSchemaData(int *numTablesPtr) convinfo = getConversions(&numConversions); if (g_verbose) - write_msg(NULL, "reading user-defined tables\n"); - tblinfo = getTables(&numTables); - tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo)); - - if (g_verbose) write_msg(NULL, "reading table inheritance information\n"); inhinfo = getInherits(&numInherits); |