postgres.git / summary / log / commit / refs

commit    9d167bc9d8b942fd976ccea5235ad8671ef60775
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Fri Jun 17 22:19:26 2011 +0000
First released in: 9.2.0, 8.2.22, 8.3.16, 8.4.9, 9.0.5, 9.1.0

    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.


src/bin/pg_dump/common.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 288b9d68f5b..54a27bee3e8 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -111,6 +111,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); @@ -164,11 +175,6 @@ getSchemaData(int *numTablesPtr) write_msg(NULL, "reading user-defined conversions\n"); 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); [parent: da021016b490]