Hi, > Currently there's no means to observe what it is doing from > outside, so the additional sixth patch is to output debug > messages about asynchronous execution.
The sixth patch did not contain one message shown in the example. Attached is the revised version. Other patches are not changed. -- Kyotaro Horiguchi NTT Open Source Software Center
>From d1ed9fe6a4e68d42653a552a680a038a0aef5683 Mon Sep 17 00:00:00 2001 From: Kyotaro Horiguchi <horiguchi.kyot...@lab.ntt.co.jp> Date: Fri, 10 Jul 2015 15:02:59 +0900 Subject: [PATCH 6/6] Debug message for async execution of postgres_fdw. --- contrib/postgres_fdw/postgres_fdw.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index dc60bcc..a8a9cc5 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -385,6 +385,25 @@ postgres_fdw_handler(PG_FUNCTION_ARGS) PG_RETURN_POINTER(routine); } +static void +postgresDebugLog(PgFdwScanState *fsstate, char *msg, void* ptr) +{ + ForeignTable *table = GetForeignTable(RelationGetRelid(fsstate->rel)); + ForeignServer *server = GetForeignServer(table->serverid); + + if (fsstate->conn) + ereport(LOG, + (errmsg ("pg_fdw: [%s/%s/%p] %s", + get_rel_name(table->relid), server->servername, + fsstate->conn, msg), + errhidestmt(true))); + else + ereport(LOG, + (errmsg ("pg_fdw: [%s/%s/--] %s", + get_rel_name(table->relid), server->servername, msg), + errhidestmt(true))); +} + /* * Read boolean server/table options * 0 is false, 1 is true, -1 is not specified @@ -928,7 +947,10 @@ postgresStartForeignScan(ForeignScanState *node) PgFdwScanState *fsstate = (PgFdwScanState *)node->fdw_state; if (!fsstate->allow_async) + { + postgresDebugLog(fsstate, "Async start admistratively denied.", NULL); return false; + } /* * On the current implemnt, scans can run asynchronously if it is the @@ -943,9 +965,11 @@ postgresStartForeignScan(ForeignScanState *node) * for details */ fetch_more_data(fsstate, START_ONLY); + postgresDebugLog(fsstate, "Async exec started.", fsstate->conn); return true; } + postgresDebugLog(fsstate, "Async exec denied.", NULL); return false; } @@ -2162,11 +2186,16 @@ fetch_more_data(PgFdwScanState *fsstate, fetch_mode cmd) */ if (fsstate != PFCgetAsyncScan(conn)) { + postgresDebugLog(fsstate, + "Changed to sync fetch (different scan)", + fsstate->conn); fetch_more_data(PFCgetAsyncScan(conn), EXIT_ASYNC); res = PFCexec(conn, sql); } else { + postgresDebugLog(fsstate, + "Async fetch", fsstate->conn); /* Get result of running async fetch */ res = PFCgetResult(conn); if (PQntuples(res) == fetch_size) @@ -2196,6 +2225,7 @@ fetch_more_data(PgFdwScanState *fsstate, fetch_mode cmd) } /* Elsewise do synchronous query execution */ + postgresDebugLog(fsstate, "Sync fetch.", conn); PFCsetAsyncScan(conn, NULL); res = PFCexec(conn, sql); } -- 1.8.3.1
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers