Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 68d977a

Browse files
committed
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.
1 parent 062780e commit 68d977a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/bin/pg_dump/common.c

+11-5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ getSchemaData(int *numTablesPtr)
105105
write_msg(NULL, "reading schemas\n");
106106
getNamespaces(&numNamespaces);
107107

108+
/*
109+
* getTables should be done as soon as possible, so as to minimize the
110+
* window between starting our transaction and acquiring per-table locks.
111+
* However, we have to do getNamespaces first because the tables get
112+
* linked to their containing namespaces during getTables.
113+
*/
114+
if (g_verbose)
115+
write_msg(NULL, "reading user-defined tables\n");
116+
tblinfo = getTables(&numTables);
117+
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
118+
108119
if (g_verbose)
109120
write_msg(NULL, "reading extensions\n");
110121
extinfo = getExtensions(&numExtensions);
@@ -183,11 +194,6 @@ getSchemaData(int *numTablesPtr)
183194
write_msg(NULL, "reading type casts\n");
184195
getCasts(&numCasts);
185196

186-
if (g_verbose)
187-
write_msg(NULL, "reading user-defined tables\n");
188-
tblinfo = getTables(&numTables);
189-
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
190-
191197
if (g_verbose)
192198
write_msg(NULL, "reading table inheritance information\n");
193199
inhinfo = getInherits(&numInherits);

0 commit comments

Comments
 (0)