From 6de0d264be66ce145d3ed726235920401cf74ebe Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Thu, 11 Mar 2021 16:00:33 +0900 Subject: [PATCH] Fix pcp_node_info failure when backend is down. From Pgpool-II 4.3, it calls db_node_role() and in turn it calls make_persistent_db_connection_noerror(). make_persistent_db_connection_noerror() called EmitErrorReport(), which sent an ERROR message to pcp frontend in case of connection error to backend. Unfortunately pcp frontends stops processing in case of receiving ERROR message from pcp server. (see process_pcp_response() in src/libs/pcp/pcp.c). To fix this eliminate calling EmitErrorReport() in make_persistent_db_connection_noerror(). This also fixes the inconsistency in the spec expressed in its comment ("does not ereports in case of an * error") and the implementation. --- src/protocol/pool_pg_utils.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/protocol/pool_pg_utils.c b/src/protocol/pool_pg_utils.c index 904350dec..18d6be4a8 100644 --- a/src/protocol/pool_pg_utils.c +++ b/src/protocol/pool_pg_utils.c @@ -191,7 +191,20 @@ make_persistent_db_connection_noerror( } PG_CATCH(); { - EmitErrorReport(); + /* + * We used to call EmitErrorReport() to log the error and send an + * error message to frontend. However if pcp frontend program + * receives an ERROR, it stops processing and terminates, which is not + * good. This is problematic especially with pcp_node_info, since it + * calls db_node_role(), and db_node_role() calls this function. So if + * the target PostgreSQL is down, EmitErrorRepor() sends ERROR message + * to pcp frontend and it stops (see process_pcp_response() in + * src/libs/pcp/pcp.c. To fix this, just eliminate calling + * EmitErrorReport(). This will suppress ERROR message but as you can + * see the comment in this function "does not ereports in case of an + * error", this should have been the right behavior in the first + * place. + */ MemoryContextSwitchTo(oldContext); FlushErrorState(); slot = NULL; -- 2.39.5