mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
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.
This commit is contained in:
parent
062780ec35
commit
68d977a737
@ -105,6 +105,17 @@ getSchemaData(int *numTablesPtr)
|
|||||||
write_msg(NULL, "reading schemas\n");
|
write_msg(NULL, "reading schemas\n");
|
||||||
getNamespaces(&numNamespaces);
|
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)
|
if (g_verbose)
|
||||||
write_msg(NULL, "reading extensions\n");
|
write_msg(NULL, "reading extensions\n");
|
||||||
extinfo = getExtensions(&numExtensions);
|
extinfo = getExtensions(&numExtensions);
|
||||||
@ -183,11 +194,6 @@ getSchemaData(int *numTablesPtr)
|
|||||||
write_msg(NULL, "reading type casts\n");
|
write_msg(NULL, "reading type casts\n");
|
||||||
getCasts(&numCasts);
|
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)
|
if (g_verbose)
|
||||||
write_msg(NULL, "reading table inheritance information\n");
|
write_msg(NULL, "reading table inheritance information\n");
|
||||||
inhinfo = getInherits(&numInherits);
|
inhinfo = getInherits(&numInherits);
|
||||||
|
Loading…
Reference in New Issue
Block a user