Re: Option to dump foreign data in pg_dump

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Luis Carril <luis(dot)carril(at)swarm64(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Option to dump foreign data in pg_dump
Date: 2020-03-23 20:17:13
Message-ID: 20200323201713.GA15029@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020-Mar-23, Alvaro Herrera wrote:

> > This seems like an overreaction. The whole point of lockTableForWorker() is
> > to avoid deadlocks, but foreign tables don't have locks, so it's not a
> > problem. I think you can just skip foreign tables in lockTableForWorker()
> > using the same logic that getTables() uses.
> >
> > I think parallel data dump would be an especially interesting option when
> > using foreign tables, so it's worth figuring this out.
>
> I agree it would be nice to implement this, so I tried to implement it.

(Here's patch for this, which of course doesn't compile)

diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
index c25e3f7a88..b3000da409 100644
--- a/src/bin/pg_dump/parallel.c
+++ b/src/bin/pg_dump/parallel.c
@@ -1316,17 +1316,33 @@ IsEveryWorkerIdle(ParallelState *pstate)
* then we know that somebody else has requested an ACCESS EXCLUSIVE lock and
* so we have a deadlock. We must fail the backup in that case.
*/
+#include "pg_dump.h"
+#include "catalog/pg_class_d.h"
static void
lockTableForWorker(ArchiveHandle *AH, TocEntry *te)
{
const char *qualId;
PQExpBuffer query;
PGresult *res;
+ DumpableObject *obj;

/* Nothing to do for BLOBS */
if (strcmp(te->desc, "BLOBS") == 0)
return;

+ /*
+ * Nothing to do for foreign tables either, since they don't support LOCK
+ * TABLE.
+ */
+ obj = findObjectByDumpId(te->dumpId);
+ if (obj->objType == DO_TABLE_DATA)
+ {
+ TableInfo *tabinfo = (TableInfo *) obj;
+
+ if (tabinfo->relkind == RELKIND_FOREIGN_TABLE)
+ return;
+ }
+
query = createPQExpBuffer();

qualId = fmtQualifiedId(te->namespace, te->tag);

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2020-03-23 20:29:02 Re: Additional size of hash table is alway zero for hash aggregates
Previous Message Alvaro Herrera 2020-03-23 20:09:11 Re: Option to dump foreign data in pg_dump