diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-06-17 18:19:02 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-06-17 18:19:02 -0400 |
commit | 68d977a73797a129913179010eea088f30e370b7 (patch) | |
tree | 67c4992d916840350b94bfd3542f6750a520a3f4 | |
parent | 062780ec35f9db630e784b27a54440017df77531 (diff) | |
download | postgresql-68d977a73797a129913179010eea088f30e370b7.tar.gz postgresql-68d977a73797a129913179010eea088f30e370b7.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.
-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 c419c2d1806..a631f64c36f 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -105,6 +105,17 @@ getSchemaData(int *numTablesPtr) write_msg(NULL, "reading schemas\n"); 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 extensions\n"); extinfo = getExtensions(&numExtensions); @@ -184,11 +195,6 @@ getSchemaData(int *numTablesPtr) getCasts(&numCasts); 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); |