Re: Option to dump foreign data in pg_dump

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Option to dump foreign data in pg_dump
Дата
Msg-id 20200323201713.GA15029@alvherre.pgsql
обсуждение исходный текст
Ответ на Option to dump foreign data in pg_dump  (Luis Carril <luis.carril@swarm64.com>)
Список 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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Option to dump foreign data in pg_dump
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Additional size of hash table is alway zero for hash aggregates