Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqMnD-004aCH-UZ for pgpool-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 02:18:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uqMnC-005KFq-3f for pgpool-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 02:18:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqMnB-005KFg-N5 for pgpool-hackers@lists.postgresql.org; Mon, 25 Aug 2025 02:18:42 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uqMn8-001aKI-1Q for pgpool-hackers@lists.postgresql.org; Mon, 25 Aug 2025 02:18:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Content-Transfer-Encoding:Content-Type: Mime-Version:References:In-Reply-To:From:Subject:Cc:To:Message-Id:Date:Sender :Reply-To:Content-ID:Content-Description; bh=azK5XcEf4otFz1qBBaBqgfKFSKs6TMeQUi2SdqUetyo=; b=mMk09oOPIWsYRWQaJpXgyqoJwt NxU/isgFREb5DdUBjDSvQAse2NE9Mur6Ylg7tzU++p23NMC/44pT/wejq9gaj+hUUv7S/GBRHw21e OdcmvSyDhEgavFzg2IIAfHBrUxYoPLdB/tLl22DFd/a8BgDGP2zkI79of0XTOgQuKZBAHdW+NbZWm /b/89b1WaQPZJ6SbtCbcsIi0yiRB4cGJNfQ66qqfB+ekYpzz3EdIVdQFcpBIELx+Ho/dNg7LMsT28 uBX7/nPsbRoqRcDR+3UmOLm8mtYrbXH7+nVznEDlZlCs5FOtSD4T9OYa9MPaIs9PbR3Oi9mAxqrsQ rJvsQSOw==; Received: from [2409:11:4120:300:3b8e:130f:5751:aaf5] (helo=localhost) by meldrar.postgresql.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.96) (envelope-from ) id 1uqMn4-003ifM-34; Mon, 25 Aug 2025 02:18:38 +0000 Date: Mon, 25 Aug 2025 11:18:25 +0900 (JST) Message-Id: <20250825.111825.1765418484481637087.ishii@postgresql.org> To: nadav@tailorbrands.com Cc: pgpool-hackers@lists.postgresql.org Subject: Re: Proposal: recent access based routing for primary-replica setups From: Tatsuo Ishii In-Reply-To: References: <20250821.192332.768193620076940871.ishii@postgresql.org> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_Aug_25_11_18_25_2025_086)--" Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2409:11:4120:300:3b8e:130f:5751:aaf5 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ----Next_Part(Mon_Aug_25_11_18_25_2025_086)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Nadav, Thank you for the patch! I have one question. How do you provide a password (sr_check_password) while executing replication_delay_source_cmd as sr_check_user? In my understanding replication_delay_source_cmd is executed through su command in your patch. In this case su command tries to read the password from terminal. I don't see such a code in the patch. BTW, I start to think that executing replication_delay_source_cmd as sr_check_user might not be a good idea. sr_check_user is a database user, not OS user. In PostgreSQL they are not necessarily the same. Also doing su in pgpool process needs to be very carefully to avoid vulnerability. Probably we just execute it as pgpool OS user? Lastly when I apply the patches using git apply, there are some trailing space errors. $ git apply ~/external-lag-feature-implementation.patch /home/t-ishii/external-lag-feature-implementation.patch:314: trailing whitespace. /home/t-ishii/external-lag-feature-implementation.patch:317: trailing whitespace. /home/t-ishii/external-lag-feature-implementation.patch:318: trailing whitespace. cmd_len = strlen(escaped_cmd) + /home/t-ishii/external-lag-feature-implementation.patch:320: trailing whitespace. /home/t-ishii/external-lag-feature-implementation.patch:322: trailing whitespace. snprintf(full_command, cmd_len, "su - %s -c '%s'", warning: squelched 4 whitespace errors warning: 9 lines add whitespace errors. $ git apply ~/external-lag-feature-tests.patch /home/t-ishii/external-lag-feature-tests.patch:87: trailing whitespace. - test_parsing.sh: Unit test for parsing logic /home/t-ishii/external-lag-feature-tests.patch:440: trailing whitespace. # Test 2: Float values warning: 2 lines add whitespace errors. Also I have some compilation errors after patching the source code. See attached compilation log. Best regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp ----Next_Part(Mon_Aug_25_11_18_25_2025_086)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="compile.log" Making all in src make[1]: Entering directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src' Making all in parser make[2]: Entering directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/parser' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/parser' Making all in libs make[2]: Entering directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/libs' Making all in pcp make[3]: Entering directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/libs/pcp' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/libs/pcp' make[3]: Entering directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/libs' make[3]: Nothing to be done for 'all-am'. make[3]: Leaving directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/libs' make[2]: Leaving directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/libs' Making all in watchdog make[2]: Entering directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/watchdog' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src/watchdog' Making all in . make[2]: Entering directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src' gcc -DHAVE_CONFIG_H -DDEFAULT_CONFIGDIR=\"/usr/local/etc\" -DPGSQL_BIN_DIR=\"/usr/local/pgsql/bin\" -I. -I../src/include -D_GNU_SOURCE -I /usr/local/pgsql/include -g -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing -c -o streaming_replication/pool_worker_child.o streaming_replication/pool_worker_child.c streaming_replication/pool_worker_child.c: In function 'do_worker_child': streaming_replication/pool_worker_child.c:266:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation] 266 | else | ^~~~ streaming_replication/pool_worker_child.c:270:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else' 270 | node_status = verify_backend_node_status(slots); | ^~~~~~~~~~~ In file included from streaming_replication/pool_worker_child.c:56: streaming_replication/pool_worker_child.c: In function 'check_replication_time_lag_with_cmd': ../src/include/utils/elog.h:397:25: warning: unused variable 'save_context_stack' [-Wunused-variable] 397 | ErrorContextCallback *save_context_stack = error_context_stack; \ | ^~~~~~~~~~~~~~~~~~ streaming_replication/pool_worker_child.c:786:2: note: in expansion of macro 'PG_TRY' 786 | PG_TRY(); | ^~~~~~ ../src/include/utils/elog.h:396:15: warning: unused variable 'save_exception_stack' [-Wunused-variable] 396 | sigjmp_buf *save_exception_stack = PG_exception_stack; \ | ^~~~~~~~~~~~~~~~~~~~ streaming_replication/pool_worker_child.c:786:2: note: in expansion of macro 'PG_TRY' 786 | PG_TRY(); | ^~~~~~ ../src/include/utils/elog.h:405:3: error: expected 'while' before 'else' 405 | else \ | ^~~~ streaming_replication/pool_worker_child.c:961:2: note: in expansion of macro 'PG_CATCH' 961 | PG_CATCH(); | ^~~~~~~~ ../src/include/utils/elog.h:412:24: error: 'save_exception_stack' undeclared (first use in this function); did you mean 'PG_exception_stack'? 412 | PG_exception_stack = save_exception_stack; \ | ^~~~~~~~~~~~~~~~~~~~ streaming_replication/pool_worker_child.c:980:2: note: in expansion of macro 'PG_END_TRY' 980 | PG_END_TRY(); | ^~~~~~~~~~ ../src/include/utils/elog.h:412:24: note: each undeclared identifier is reported only once for each function it appears in 412 | PG_exception_stack = save_exception_stack; \ | ^~~~~~~~~~~~~~~~~~~~ streaming_replication/pool_worker_child.c:980:2: note: in expansion of macro 'PG_END_TRY' 980 | PG_END_TRY(); | ^~~~~~~~~~ ../src/include/utils/elog.h:413:25: error: 'save_context_stack' undeclared (first use in this function); did you mean 'error_context_stack'? 413 | error_context_stack = save_context_stack; \ | ^~~~~~~~~~~~~~~~~~ streaming_replication/pool_worker_child.c:980:2: note: in expansion of macro 'PG_END_TRY' 980 | PG_END_TRY(); | ^~~~~~~~~~ streaming_replication/pool_worker_child.c:743:9: warning: variable 'cmd_allocated' set but not used [-Wunused-but-set-variable] 743 | bool cmd_allocated = false; | ^~~~~~~~~~~~~ In file included from streaming_replication/pool_worker_child.c:56: streaming_replication/pool_worker_child.c: At top level: ../src/include/utils/elog.h:414:4: error: expected identifier or '(' before 'while' 414 | } while (0) | ^~~~~ streaming_replication/pool_worker_child.c:980:2: note: in expansion of macro 'PG_END_TRY' 980 | PG_END_TRY(); | ^~~~~~~~~~ streaming_replication/pool_worker_child.c:983:2: error: expected identifier or '(' before 'if' 983 | if (line) | ^~ streaming_replication/pool_worker_child.c:985:2: error: expected identifier or '(' before 'if' 985 | if (escaped_cmd) | ^~ streaming_replication/pool_worker_child.c:987:2: error: expected identifier or '(' before 'if' 987 | if (cmd_allocated && command) | ^~ streaming_replication/pool_worker_child.c:990:2: warning: data definition has no type or storage class 990 | error_context_stack = callback.previous; | ^~~~~~~~~~~~~~~~~~~ streaming_replication/pool_worker_child.c:990:2: warning: type defaults to 'int' in declaration of 'error_context_stack' [-Wimplicit-int] streaming_replication/pool_worker_child.c:990:2: error: conflicting types for 'error_context_stack' In file included from streaming_replication/pool_worker_child.c:56: ../src/include/utils/elog.h:360:42: note: previous declaration of 'error_context_stack' was here 360 | extern PGDLLIMPORT ErrorContextCallback *error_context_stack; | ^~~~~~~~~~~~~~~~~~~ streaming_replication/pool_worker_child.c:990:24: error: 'callback' undeclared here (not in a function); did you mean 'calloc'? 990 | error_context_stack = callback.previous; | ^~~~~~~~ | calloc streaming_replication/pool_worker_child.c:991:1: error: expected identifier or '(' before '}' token 991 | } | ^ In file included from streaming_replication/pool_worker_child.c:56: streaming_replication/pool_worker_child.c: In function 'get_query_result': ../src/include/utils/elog.h:397:46: warning: initialization of 'ErrorContextCallback *' {aka 'struct ErrorContextCallback *'} from 'int' makes pointer from integer without a cast [-Wint-conversion] 397 | ErrorContextCallback *save_context_stack = error_context_stack; \ | ^~~~~~~~~~~~~~~~~~~ streaming_replication/pool_worker_child.c:1099:2: note: in expansion of macro 'PG_TRY' 1099 | PG_TRY(); | ^~~~~~ ../src/include/utils/elog.h:408:24: warning: assignment to 'int' from 'ErrorContextCallback *' {aka 'struct ErrorContextCallback *'} makes integer from pointer without a cast [-Wint-conversion] 408 | error_context_stack = save_context_stack | ^ streaming_replication/pool_worker_child.c:1103:2: note: in expansion of macro 'PG_CATCH' 1103 | PG_CATCH(); | ^~~~~~~~ ../src/include/utils/elog.h:413:23: warning: assignment to 'int' from 'ErrorContextCallback *' {aka 'struct ErrorContextCallback *'} makes integer from pointer without a cast [-Wint-conversion] 413 | error_context_stack = save_context_stack; \ | ^ streaming_replication/pool_worker_child.c:1112:2: note: in expansion of macro 'PG_END_TRY' 1112 | PG_END_TRY(); | ^~~~~~~~~~ make[2]: *** [Makefile:883: streaming_replication/pool_worker_child.o] Error 1 make[2]: Leaving directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src' make[1]: *** [Makefile:949: all-recursive] Error 1 make[1]: Leaving directory '/home/t-ishii/work/Pgpool-II/current/pgpool2/src' make: *** [Makefile:413: all-recursive] Error 1 ----Next_Part(Mon_Aug_25_11_18_25_2025_086)----