pgpool2.git
13 hours agoTest: stabilize 037.failover_session. master
Tatsuo Ishii [Tue, 25 Nov 2025 09:45:01 +0000 (18:45 +0900)]
Test: stabilize 037.failover_session.

On some platform (in my case Rocky Linux 10 running on VitualBox)
fails to finish shutdownall after test1.  This could be caused by the
failover in the test to fail to restore the signal handler which
should accept shutdown signal from shutdownall. Adding "sleep 5"
before shutdownall seems to mitigate the problem.

Author: Tatsuo Ishii <ishii@postgresql.org>
Backpatch-through: v4.5

20 hours agoDoc: add 4.7.0 english release note.
Bo Peng [Tue, 25 Nov 2025 03:37:39 +0000 (12:37 +0900)]
Doc: add 4.7.0 english release note.

4 days agoRevert "Fix %patch macro usage in RPM spec."
Bo Peng [Fri, 21 Nov 2025 05:10:37 +0000 (14:10 +0900)]
Revert "Fix %patch macro usage in RPM spec."

This reverts commit d8ddc3f47b59e98242043f28743398b44481edbb.

The change from `%patchN` to `%patch N` breaks builds on
Rocky Linux 8 / RHEL 8 where this newer %patch syntax is not supported.

4 days agoUpdate major version information in configuration file.
Bo Peng [Fri, 21 Nov 2025 02:18:45 +0000 (11:18 +0900)]
Update major version information in configuration file.

7 days agoStart 4.8 development.
Taiki Koshino [Tue, 18 Nov 2025 01:36:51 +0000 (10:36 +0900)]
Start 4.8 development.

7 days agoDoc: update release note.
Bo Peng [Tue, 18 Nov 2025 00:44:44 +0000 (09:44 +0900)]
Doc: update release note.

7 days agoDoc: update release note.
Bo Peng [Tue, 18 Nov 2025 00:34:08 +0000 (09:34 +0900)]
Doc: update release note.

9 days agoFix segfault with CopyOut.
Tatsuo Ishii [Sun, 16 Nov 2025 06:43:46 +0000 (15:43 +0900)]
Fix segfault with CopyOut.

When "COPY relname TO STDOUT" is executed in the extended query
protocol mode, pgpool segfaulted.

When read_kind_from_backend() reads a message from backend, it
extracts the corresponding entry from the pending message queue when
processing extended query protocol messages. However, if the head of
the message queue is an "execute" message, some of incoming message
types are exceptional because other than CommandComplete message
(which means the execute message finishes) may come from backend. This
includes DataRow, ErrorResponse, NoticeMessage. Unfortunately we
overlooked that 'H' (CopyOutResponse) is in the group too. Thus when
CopyOutResponse comes from backend, the execute pending message is
removed. If the next message from frontend is Sync (it's often
happens), read_kind_from_backend() sets session_context->query_context
to NULL, and calls pool_unset_query_in_progress(), which accesses
session_context->query_context and segfaults.

The fix is, to add CopyOutResponse to the exception list. Just in
case, we also add 'd' (CopyData) and 'c' (CopyDone) to the list. This
may not be actually necessary since CopyData and CopyDone are
processced in CopyDataRows() though.

Add regression test case to 126.copy_hang (master and v4.7) or
076.copy_hang (v4.6 or before).

Author: Tatsuo Ishii <ishii@postgresql.org>
Reported-by: https://github.com/tetesh
Reviewed-by: Bo Peng <pengbo@sraoss.co.jp>
Discussion: https://github.com/pgpool/pgpool2/issues/133
Backpatch-through: v4.2

11 days agoPrepare Release Note.
Taiki Koshino [Fri, 14 Nov 2025 01:39:06 +0000 (10:39 +0900)]
Prepare Release Note.

12 days agoEnable AM_MAINTAINER_MODE.
Taiki Koshino [Thu, 13 Nov 2025 06:15:00 +0000 (15:15 +0900)]
Enable AM_MAINTAINER_MODE.

12 days agoDisable AM_MAINTAINER_MODE.
Taiki Koshino [Thu, 13 Nov 2025 06:12:08 +0000 (15:12 +0900)]
Disable AM_MAINTAINER_MODE.

13 days agoUpdate the OS version in the documentation.
Taiki Koshino [Wed, 12 Nov 2025 08:12:06 +0000 (17:12 +0900)]
Update the OS version in the documentation.

13 days agoFix %patch macro usage in RPM spec.
Taiki Koshino [Wed, 12 Nov 2025 08:01:03 +0000 (17:01 +0900)]
Fix %patch macro usage in RPM spec.

Replaced `-%patchN` with `%patch N` in %prep section to properly apply patches.

2 weeks agoRemove unnecessary application_name treatment.
Tatsuo Ishii [Fri, 7 Nov 2025 07:54:43 +0000 (16:54 +0900)]
Remove unnecessary application_name treatment.

Commit c20858797eafe377b30166b467d2a36de89768e1 added an treatment to
send "set application_name" command to backend when reusing existing
connection. The reason were:

(1) to set application_name parameter to proper value, which is the
value specified in the startup packet when the connection was created.

(2) to return application_name parameter status message to frontend.

However, (1) is not necessary, because when the previous connection is
closed, queries in reset_query_list are executed and the list usually
includes "DISCARD ALL", which reset the application_name value to the
previous one which was set when the connection was established.  Also
(2) is not necessary either, because send_params() sends all necessary
parameter status messages to frontend including application_name.

For these reasons, I think the treatment added in
c20858797eafe377b30166b467d2a36de89768e1 is not necessary. This commit
just removes the treatment. Also this will enhance the performance
when some of backend nodes are in geographically distant location, by
eliminating the time to send application_name to such a node and wait
for the response.

Author: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://github.com/pgpool/pgpool2/issues/130
Backpatch-through: v4.2.

3 weeks agoFix pgpool_adm Makefile.
Tatsuo Ishii [Tue, 4 Nov 2025 00:51:02 +0000 (09:51 +0900)]
Fix pgpool_adm Makefile.

The Makefile set SHLIB_LINK. However nowadays PostgreSQL provides most
of the SHLIB_LINK options in Makefile.global except
-L../../libs/pcp/.libs -lpcp. Moreover '${prefix}/lib', which is
currently in the option, is harmful because while building rpm
packages, check_rpaths complains that /libs is in rpath.  So remove
all the options except -L../../libs/pcp/.libs -lpcp.

Backpatch-through: v4.2

3 weeks agoBump libpcp.so version.
Tatsuo Ishii [Wed, 29 Oct 2025 02:57:36 +0000 (11:57 +0900)]
Bump libpcp.so version.

Now that src/utils/pool_health_check_stats.c has been changed to add
more members to the return value of pool_report_pools_offsets(), we
bump the libpcp.so version from Pgpool-II 4.6's 2.0.0 to 3.0.0.

Author: Tatsuo Ishii <ishii@postgresql.org>

4 weeks agoRetire Slony mode.
Tatsuo Ishii [Tue, 28 Oct 2025 23:42:45 +0000 (08:42 +0900)]
Retire Slony mode.

Previously Pgpool-II accepted "slony mode" as one of the
backend_clustering_mode to support Slony-I
(https://www.slony.info/). However the latest Slony-I was released in
2022, nearly 3 years ago at this point. And we heard nothing from
users about retiring Slony mode. This suggests that there would be no
active Slony-I mode users. So let's drop Slony-I support.

Author: Tatsuo Ishii <ishii@postgresql.org>
Reviewed-by: Bo Peng <pengbo@sraoss.co.jp>
Discussion: [pgpool-general: 9486] Retiring slony mode
    https://www.pgpool.net/pipermail/pgpool-general/2025-May/009489.html
Discussion: https://www.postgresql.org/message-id/20250722.153130.1007226654125839063.ishii%40postgresql.org

4 weeks agoAdd debug message to send_params().
Tatsuo Ishii [Sat, 25 Oct 2025 12:27:57 +0000 (21:27 +0900)]
Add debug message to send_params().

Previously there was no way to know pgpool sent parameter status
messages to frontend when connection cache is used.

This commit adds debug1 message to send_params() so that it prints
debug message when it sends the parameter status messages to frontend.

Author: Tatsuo Ishii <ishii@postgresql.org>

5 weeks agoFix unexpected EOF in pgpool_setup.
Bo Peng [Wed, 15 Oct 2025 09:21:21 +0000 (18:21 +0900)]
Fix unexpected EOF in pgpool_setup.

Fix pgpool_setup unexpected EOF introduced in the previous commit (25ad5e46615c3ed337a8cefe7e0563d8b89ca18d).

6 weeks agoChange regression test logdir parameter to work_dir and update log_directory value...
Taiki Koshino [Tue, 14 Oct 2025 04:25:12 +0000 (13:25 +0900)]
Change regression test logdir parameter to work_dir and update log_directory value in the document.

6 weeks agoChange the value of 'log_directory' parameter to '/var/log/pgpool' when building...
Taiki Koshino [Tue, 14 Oct 2025 02:00:07 +0000 (11:00 +0900)]
Change the value of 'log_directory' parameter to '/var/log/pgpool' when building RPM package.

6 weeks agoChange the value of 'work_dir' parameter to '/var/lib/pgpool' when building RPM package.
Taiki Koshino [Tue, 14 Oct 2025 01:58:50 +0000 (10:58 +0900)]
Change the value of 'work_dir' parameter to '/var/lib/pgpool' when building RPM package.

6 weeks agoFix DelegateIPAssignMessage to properly handle delegate_IP as a char* using pfree...
Taiki Koshino [Tue, 14 Oct 2025 01:00:49 +0000 (10:00 +0900)]
Fix DelegateIPAssignMessage to properly handle delegate_IP as a char* using pfree() and pstrdup().

6 weeks agoRename 'logdir' parameter to 'work_dir'.
Taiki Koshino [Tue, 14 Oct 2025 00:59:39 +0000 (09:59 +0900)]
Rename 'logdir' parameter to 'work_dir'.

Previously, the directory for storing pgpool_status and lock files was specified by the logdir parameter.
However, since the name logdir was confusing, the parameter has been renamed to work_dir for clarity.

6 weeks agoMake time calculations always long long.
Tatsuo Ishii [Fri, 3 Oct 2025 12:10:50 +0000 (21:10 +0900)]
Make time calculations always long long.

Previously pgpool assumed that time_t to be a simple long. This causes
a lot of compile time warnings on certain systems, for example
OpenBSD because on the system time_t is __int64, which results in long
long. This commit upcasts such calculations to long long to avoid the
issue.

This way times can't get truncated and for the places where time_t is
actually used as a time and not a time diff this would allow pgpool to
keep working correctly post Y2038 on 64 bit clean time_t systems
(e.g. i386 OpenBSD).

Moreover, json_get_long_value_for_key is changed to
json_get_llong_value_for_key and changed the parameter to long long.
This makes it more in line _json_value's integer, which is defined as
int64. This should also give 32 bit platforms proper retrieval of the
max value of an integer and may or may not solve some weird integer
overflow issues.

Backpatch for 4.6 was rebased by Gyorgy Sarvari.

Author: Martijn van Duren <pgpool@list.imperialat.at>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Reviewed-by: Gyorgy Sarvari <skandigraun@gmail.com>
Backpatch-through: v4.6
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2025-May/004584.html
Discussion: https://www.postgresql.org/message-id/20251003.211957.2067537305399895611.ishii%40postgresql.org
Discussion: https://github.com/pgpool/pgpool2/pull/128

7 weeks agoUpdate mailing list address to use pgpool-hackers@lists.postgresql.org instead of...
Bo Peng [Mon, 6 Oct 2025 00:52:38 +0000 (09:52 +0900)]
Update mailing list address to use pgpool-hackers@lists.postgresql.org instead of pgpool-hackers@pgpool.net.

7 weeks agoFix regression introduced by the previous commit (df277163720a248f108192329de58077cd3...
Bo Peng [Sun, 5 Oct 2025 10:35:14 +0000 (19:35 +0900)]
Fix regression introduced by the previous commit (df277163720a248f108192329de58077cd35ea4e), which caused a syntax error in "PGPOOL SET CACHE DELETE".

7 weeks agoFeature: Import PostgreSQL 18 new parser.
Bo Peng [Fri, 3 Oct 2025 10:29:19 +0000 (19:29 +0900)]
Feature: Import PostgreSQL 18 new parser.

Major changes of PostgreSQL 18 parser include:
- Allow generated columns to be virtual
- Add OLD/NEW support to RETURNING in DML queries
- Addition of various constraints (e.g. WITHOUT OVERLAPS, ENFORCED / NOT ENFORCED)
- etc.

7 weeks agoPrevent watchdog split-brain scenario in some corner cases.
Tatsuo Ishii [Fri, 3 Oct 2025 01:44:10 +0000 (10:44 +0900)]
Prevent watchdog split-brain scenario in some corner cases.

Watchdog uses two methods for communication: beacon message and
heartbeat.  If the heartbeat is not working yet, it is possible that
split-brain occurs if beacon messages are not received by standby
nodes more than 30 seconds (see watchdog_state_machine_standby). In
this case other watchdog node becomes new leader node. Problem is, the
former leader node remains leader too, thus there are two leader
nodes: split-brain.

Suppose we have 3 watchdog nodes (node 0, 1, 2) and node 2 was not
started due a maintenace work. In this case life check is not started.

$ pcp_watchdog_info -p 50005
3 3 NO localhost:50000 Linux tishii-CFSV9-2 localhost

localhost:50004 Linux tishii-CFSV9-2 localhost 50004 50006 7 STANDBY 0 MEMBER
localhost:50000 Linux tishii-CFSV9-2 localhost 50000 50002 4 LEADER 0 MEMBER
Not_Set localhost 50008 50010 0 DEAD 0 MEMBER

Then to stop the beacon signal, send STOP signal to node0 watchdg
process. Node 1 is promoted and now we have two leader nodes 0 and 1.

$ pcp_watchdog_info -p 50005
3 3 NO localhost:50004 Linux tishii-CFSV9-2 localhost

localhost:50004 Linux tishii-CFSV9-2 localhost 50004 50006 4 LEADER 0 MEMBER
localhost:50000 Linux tishii-CFSV9-2 localhost 50000 50002 4 LEADER 0 MEMBER
Not_Set localhost 50008 50010 0 DEAD 0 MEMBER

This commit tries to prevent having two leaders by revoking the former
leader. If a node detects beacon message from leader node being lost
more than 2 times (3 * BEACON_MESSAGE_INTERVAL_SECONDS), leader node
is set to LOST state and new leader node election process is triggered
by calling set_state(WD_JOINING).

Backpatch-through: v4.2

7 weeks agoPrevent FATAL error when non-existing prepared statement is given.
Tatsuo Ishii [Fri, 3 Oct 2025 01:18:45 +0000 (10:18 +0900)]
Prevent FATAL error when non-existing prepared statement is given.

Previously Bind() raised FATAL error if non-existing prepared statement was given.
This is different from PostgreSQL's behavior.

\bind_named stmt2 'baz' \g
ERROR:  prepared statement "stmt2" does not exist

This commit let Bind() check the existence of prepared statement and
if it does not exist, send an ERROR message to frontend. Note that no
log is left in the log file. This is not preferred action but currently
it's not possible to leave log.

Backpatch-through: v4.2

8 weeks agoTest: add log_client_messages to 124.bug700_memqcache_segfault regression test.
Tatsuo Ishii [Tue, 30 Sep 2025 09:51:22 +0000 (18:51 +0900)]
Test: add log_client_messages to 124.bug700_memqcache_segfault regression test.

To investigate recent failure of the test, add:
log_client_messages = on

8 weeks agoTest: adapt 023.ssl_connection to PostgreSQL 18.
Tatsuo Ishii [Tue, 30 Sep 2025 09:04:06 +0000 (18:04 +0900)]
Test: adapt 023.ssl_connection to PostgreSQL 18.

PostgreSQL 18 heavily changed psql's \conninfo output format, which
made the test fail because the test relies on \conninfo. This commit
makes the test script aware the PostgreSQL version to fix the issue.

Backpatch-through: v4.2

8 weeks agoTest: add log_backend_messages to 124.bug700_memqcache_segfault regression test.
Tatsuo Ishii [Sat, 27 Sep 2025 10:08:49 +0000 (19:08 +0900)]
Test: add log_backend_messages to 124.bug700_memqcache_segfault regression test.

To investigate recent failure of the test, add:
log_backend_messages = terse

2 months agoFix pg_enc not working if both -p and -P are provided.
Tatsuo Ishii [Wed, 24 Sep 2025 01:26:14 +0000 (10:26 +0900)]
Fix pg_enc not working if both -p and -P are provided.

In the original report (https://github.com/pgpool/pgpool2/issues/129:

[root@test1 bin]# ./pg_enc -p -P
db password:
encryption key:
encryption key not provided

Also I found a misleading comment:
case 'p': /* prompt for postgres password */

This is not appropriate since the password is not provided to
PostgreSQL. It is totally unrelated to the issue but I replaced it
with following in this opportunity:

case 'p': /* prompt for password to be encrypted */

Author: jinyang liu <liujy@highgo.com>
Discussion: https://www.postgresql.org/message-id/7f18c30b.237.1997555ca11.Coremail.liujy%40highgo.com
Backpatch-through: v4.2

2 months agoFix wrong positioned comment.
Tatsuo Ishii [Mon, 22 Sep 2025 02:29:11 +0000 (11:29 +0900)]
Fix wrong positioned comment.

Backpatch-through: v4.2

2 months agoFix compiling issue on 32-bit environments.
Tatsuo Ishii [Wed, 17 Sep 2025 23:24:13 +0000 (08:24 +0900)]
Fix compiling issue on 32-bit environments.

It is reported that compiling src/parser/snprintf.c on 32-bit
environments fails due to undefined functions (isnan() and
ininf()). They come from math.h so include it.  snprintf.c was
imported from PostgreSQL long time ago. If we look into the original
file (src/port/snprintf.c) it actually has "#include <math.h>"
already. Including math.h was provided as a pull request:
https://github.com/pgpool/pgpool2/pull/128

I also added a minor modification to the patch to reorder the
positions of include files.

Author: Gyorgy Sarvari <skandigraun@gmail.com>
Discussion: https://www.postgresql.org/message-id/20250917.194736.353755422175293639.ishii%40postgresql.org
Backpatch-through: v4.2

2 months agoUpdate doc about "Setting up PostgreSQL standby" in "8.2. Pgpool-II + Watchdog Setup...
Taiki Koshino [Wed, 17 Sep 2025 07:15:11 +0000 (16:15 +0900)]
Update doc about "Setting up PostgreSQL standby" in "8.2. Pgpool-II + Watchdog Setup Example".

Add a note that when setting up a standby without online recovery, do not write primary_conninfo to postgresql.auto.conf.

Discussion: https://github.com/pgpool/pgpool2/issues/67
Backpatch-through: v4.2

2 months agoFix safer directory deletion in Bash in recovery_1st_stage.sample.
Taiki Koshino [Wed, 10 Sep 2025 06:28:01 +0000 (15:28 +0900)]
Fix safer directory deletion in Bash in recovery_1st_stage.sample.

Quote variables in rm commands to avoid accidental deletion:
rm -rf "${DEST_NODE_PGDATA}"

If the variable is empty, rm could delete unexpected files or directories.

2 months agoAllow to compile against gcc 15 (C23).
Tatsuo Ishii [Tue, 9 Sep 2025 01:02:35 +0000 (10:02 +0900)]
Allow to compile against gcc 15 (C23).

This commit includes multiple fixes to compile Pgpool-II in Fedora 42,
which uses gcc 15 (C23).

- Modify pool_type.h. "bool" is now standard in C99 and
  above. PostgreSQL decided to require C99 to compile it. So we follow
  the way, which is just including <stdbool.h>.  Also we define
  TRUE/FALSE to (bool) 1 and (bool) 0 respectively. They are used only
  in Windows build in PostgreSQL but we still use them in some
  places. Eventually we should replace it with true/false since we do
  not support Windows.

- It is now required that function pointer arguments matches the
  function prototype to be called. For example:
  static pid_t worker_fork_a_child(ProcessType type, void (*func) (), void *params);
  should be:
  static pid_t worker_fork_a_child(ProcessType type, void (*func) (void *), void *params);

  Also the prototype of pool_create_relcache() is changed,

- raw_expression_tree_walker() calls walker() in many places. Now
  callers of walker() should cast the first argument of it using (Node
  *). We replace the call:
return walker(((RangeVar *) node)->alias, context);
with:
return WALK(((RangeVar *) node)->alias, context);
where WALK is defined as:
    #define WALK(n,c) walker((Node *) (n), c)

- Note: we have lots of warnings regarding OpenSSL while compiling
  Pgpool-II in Fedora42. The version used in Fedora42:

  $ openssl -version
  OpenSSL 3.2.4 11 Feb 2025 (Library: OpenSSL 3.2.4 11 Feb 2025)

  The fix is not included in this commit. We need
  to look into it in the future.

Discussion: https://github.com/pgpool/pgpool2/issues/124
Backpatch-through: v4.6

2 months agoTest: renumber regression tests.
Tatsuo Ishii [Mon, 8 Sep 2025 06:01:28 +0000 (15:01 +0900)]
Test: renumber regression tests.

Under src/test/regression/tests we traditionally assign 001-049 for
tests for features and 050-999 for bugs. However we are running out
the range 001-049. To solve the problem, this commit renames 50 or
higher tests to 50 + 50 = 100 and higher. Also add
src/test/regression/tests/README to explain the test numbering policy.
Moreover src/test/regress.sh is modified to not misunderstand flat
files under tests is not for testing.

2 months agoFix point less warning in query cache invalidation.
Tatsuo Ishii [Fri, 5 Sep 2025 09:11:04 +0000 (18:11 +0900)]
Fix point less warning in query cache invalidation.

When memcached support is disabled, query cache invalidation by query
emitted point less warning. This makes 006.memcached regression test
failed.

PGPOOL SET CACHE DELETE '/*FORCE QUERY CACHE*/SELECT 1;';
WARNING:  failed to delete query cache on memcached, memcached support is not enabled

Backpatch-through: v4.6

2 months agoFix query cache when pgpool is built without memcached.
Tatsuo Ishii [Fri, 5 Sep 2025 08:12:12 +0000 (17:12 +0900)]
Fix query cache when pgpool is built without memcached.

When configure is not provided --with-memcached, compiler error
occured.

    query_cache/pool_memqcache.c:542:17: è­¦å‘Š: 'free' called on pointer 'cih' with nonzero offset 24 -Wfree-nonheap-objec
    t]
      542 |                 free(ptr);
          |                 ^~~~~~~~~
    query_cache/pool_memqcache.c:2843:15: å‚™è€ƒ: returned from 'pool_cache_item_header'
     2843 |         cih = pool_cache_item_header(cacheid);
          |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    This is caused by the code block:
            if (!pool_is_shmem_cache())
            {
                    free(ptr);
            }

The compiler thought that "ptr" could be the value returned by
pool_cache_item_header(), because the compiler does not understand
pool_is_shmem_cache() could return false only when memcached is
enabled. To fix this, surround the code block above with #ifdef
USE_MEMCACHED.

Reported-by: Bo Peng <pengbo@sraoss.co.jp>
Backpatch-through: v4.2

2 months agoFix query cache lock file handling.
Tatsuo Ishii [Thu, 4 Sep 2025 05:59:26 +0000 (14:59 +0900)]
Fix query cache lock file handling.

Query cache module creates a lock file under logdir for concurrency
control. However, there were bugs in the handling:

1) Garbage file "QUERY_CACHE_LOCK_FILE" was created by pgpool main
   process.

2) The lock file was not removed upon pgpool shutdown.

This commit fixes the bugs.

Author: Tatsuo Ishii <ishii@postgresql.org>
Reported-by: Bo Peng <pengbo@sraoss.co.jp>
Reviewed-by: Bo Peng <pengbo@sraoss.co.jp>
Backpatch-through: v4.4

2 months agoConsider local heartbeat interfaces in watchdog config checks.
Bo Peng [Mon, 1 Sep 2025 02:30:35 +0000 (11:30 +0900)]
Consider local heartbeat interfaces in watchdog config checks.

This is a follow-up to commit 94b62a9.

2 months agoFix compile warning on Fedora 42.
Bo Peng [Mon, 1 Sep 2025 02:28:47 +0000 (11:28 +0900)]
Fix compile warning on Fedora 42.

2 months agoTest: unbreak 039.log_backend_messages.
Tatsuo Ishii [Sun, 31 Aug 2025 12:06:01 +0000 (21:06 +0900)]
Test: unbreak 039.log_backend_messages.

Commit 8ff2b9f6e mistakenly put synchronous commit parameters in
pgpool.conf.  Unbreak the test by putting the parameters in
postgresql.conf. Also check if clustering mode is streaming
replication. Because that parameters causes suspends PostgreSQL if
clustering mode is other than streaming replication.

Backpatch-through: v4.6

2 months agoTest: stabilize 039.log_backend_messages test.
Tatsuo Ishii [Sun, 31 Aug 2025 06:17:54 +0000 (15:17 +0900)]
Test: stabilize 039.log_backend_messages test.

In the test a query is sent to standby server right after rows are
inserted into primary server.  Due to a replication lag, the inserted
rows could not be found on the standby in slower machines.  This
commit tries to fix the issue by using synchronous replication with
remote_apply option.

Backpatch-through: v4.2

2 months agoTest: fix ruby script in 010.rewrite_timestamp.
Tatsuo Ishii [Fri, 29 Aug 2025 07:15:55 +0000 (16:15 +0900)]
Test: fix ruby script in 010.rewrite_timestamp.

The ruby script used "File.exists", which is said to be obsoleted in
newer version of Ruby.  Replace it with "File.exist".

Backpatch-through: v4.2

2 months agoTest: tweak timeout in 034 and 075 tests.
Tatsuo Ishii [Fri, 29 Aug 2025 06:48:57 +0000 (15:48 +0900)]
Test: tweak timeout in 034 and 075 tests.

034.promote_node and 075.detach_primary_left_down_node set the timeout
60 seconds for finishing follow primary script.  It turns out that
these timeout values are not long enough, and sometimes caused false
errors. So make them from 60 seconds to 120 seconds.

Backpath-through: v4.2

2 months agoTest: add ssl_ecdh_curve test to 023.ssl_connection.
Tatsuo Ishii [Wed, 27 Aug 2025 01:14:53 +0000 (10:14 +0900)]
Test: add ssl_ecdh_curve test to 023.ssl_connection.

023.ssl_connection did not cover the test for ssl_ecdh_curve.  This
commit tests it using bad ssl_ecdh_curve parameter to see if connection
between frontend and pgpool fails.

Author: Tatsuo Ishii <ishii@postgresql.org>
Backpatch-through: v4.2

3 months agoDoc: Fix releasenote link.
Taiki Koshino [Tue, 26 Aug 2025 04:44:28 +0000 (13:44 +0900)]
Doc: Fix releasenote link.

3 months agoFix watchdog_setup bug.
Tatsuo Ishii [Fri, 22 Aug 2025 06:35:48 +0000 (15:35 +0900)]
Fix watchdog_setup bug.

Fix bug in commit 534e04a0e.

- If no argument is specified, watchdog_setup complains a shell script error.
- When VIP is requested, delegate_ip, if_up_cmd and if_up_cmd are
  added to pgpool.conf multiple times.

Reviewed-by: Bo Peng <pengbo@sraoss.co.jp
Author: Tatsuo Ishii <ishii@postgresql.org>

3 months agoFeature: Restrict watchdog and heartbeat receiver to listen only on configured addresses.
Bo Peng [Fri, 22 Aug 2025 04:37:58 +0000 (13:37 +0900)]
Feature: Restrict watchdog and heartbeat receiver to listen only on configured addresses.

Previously, both the watchdog and heartbeat receiver processes listen on all interfaces.
For security reasons, they now listen only on the addresses
specified by "hostname" and "heartbeat_hostname".

3 months agoDoc: fix watchdog_setup manual.
Tatsuo Ishii [Fri, 22 Aug 2025 00:01:06 +0000 (09:01 +0900)]
Doc: fix watchdog_setup manual.

It mistakenly stated that heartbeart is not setup in watchdog_setup.

Auther: Tatsuo Ishii <ishii@postgresql.org>
Backpatch-through: V4.2

3 months agoFeature: allow to specify VIP in watchdog_setup.
Tatsuo Ishii [Thu, 21 Aug 2025 23:24:38 +0000 (08:24 +0900)]
Feature: allow to specify VIP in watchdog_setup.

This commit allows to specify VIP parameter (delegate_ip) in
watchdog_setup using new option "-vip [ip]". If ip is omitted,
'127.0.0.1' is assumed. Even if vip option is specified, pgpool will
not actually set the VIP to the system: if_up_cmd, if_down_cmd are
just set to echo command and do nothing except emit a log. This option
is intended to trace the action of Pgpool-II regarding VIP handling.

Author: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://www.postgresql.org/message-id/20250820.151646.1640218512808280876.ishii%40postgresql.org

3 months agoDoc: add release notes.
Taiki Koshino [Tue, 19 Aug 2025 01:36:06 +0000 (10:36 +0900)]
Doc: add release notes.

3 months agoDoc: Update "8.3. Replication Mode and Snapshot Isolation Mode Configuration Example...
Taiki Koshino [Tue, 19 Aug 2025 01:33:14 +0000 (10:33 +0900)]
Doc: Update "8.3. Replication Mode and Snapshot Isolation Mode Configuration Example" Document.

Updated the link to the example script and the explanation in the "8.3.3. Before you begin" section.

3 months agoCleanup watchdog source code.
Tatsuo Ishii [Sat, 16 Aug 2025 03:36:42 +0000 (12:36 +0900)]
Cleanup watchdog source code.

- Remove wd_is_upper_ok() from wd_utils.h because there's no actual
  definition for it.

- Make wd_get_ping_result() and wd_issue_ping_command() static. It's
  only used in wd_ping.c.

Backpatch-through: master only

3 months agoUpdate pgpool.spec to add pgpool_adm--1.6.sql and pgpool_adm--1.5--1.6.sql.
Bo Peng [Fri, 15 Aug 2025 12:20:29 +0000 (21:20 +0900)]
Update pgpool.spec to add pgpool_adm--1.6.sql and pgpool_adm--1.5--1.6.sql.

3 months agoUpdate rpmbuild patch files.
Bo Peng [Fri, 15 Aug 2025 08:50:22 +0000 (17:50 +0900)]
Update rpmbuild patch files.

3 months agoUpdate rpmbuild patch files.
Bo Peng [Fri, 15 Aug 2025 08:24:24 +0000 (17:24 +0900)]
Update rpmbuild patch files.

3 months agoFix comment in watchdog.
Tatsuo Ishii [Fri, 15 Aug 2025 07:37:41 +0000 (16:37 +0900)]
Fix comment in watchdog.

Fix a comment in watchdog_state_machine_standby(). When commit b2f1526958 changed from:
last_rcv_sec >= (2 * BEACON_MESSAGE_INTERVAL_SECONDS))
to:
last_rcv_sec >= (3 * BEACON_MESSAGE_INTERVAL_SECONDS))
The comment below was left unchanged "two" instead of "three".
Also fix small typo.

Backpatch-though: master only

3 months agoChange log_pcp_processes default to off.
Tatsuo Ishii [Fri, 15 Aug 2025 04:40:32 +0000 (13:40 +0900)]
Change log_pcp_processes default to off.

Previously log_pcp_processes default was on, and it could produce
excessive log lines if admins use pcp commands frequently to monitor
pgpool status.  Also the log is kind of debugging message, thus it is
best to change its default value to off.

Discussion: https://www.postgresql.org/message-id/20250815.111100.2261166502134199972.ishii%40postgresql.org
Backpatch-through: master only

3 months agoUpdate pgpool.spec to prevent RPM build errors.
Bo Peng [Wed, 30 Apr 2025 11:06:28 +0000 (20:06 +0900)]
Update pgpool.spec to prevent RPM build errors.

3 months agoEmit warning if life check has not started yet.
Tatsuo Ishii [Wed, 13 Aug 2025 11:08:08 +0000 (20:08 +0900)]
Emit warning if life check has not started yet.

Currently lifecheck emits a log only when life check becomes
ready. This is inconvenient for admins since they need to keep on
watching log file until life check is ready. This commit makes the
life check process to emit additional warnings periodically until life
check has started. The interval of the warnings is wd_interval * 10
seconds. However for the first time at lifecheck starting, no warning
is emitted since it is likely that lifecheck is not ready at that
point.

3 months agoFix comment and update copyright year in pgpool_main.c
Tatsuo Ishii [Thu, 7 Aug 2025 06:58:38 +0000 (15:58 +0900)]
Fix comment and update copyright year in pgpool_main.c

3 months agoDoc: Update sample script links in "8.2. Pgpool-II + Watchdog Setup Example"
Taiki Koshino [Wed, 6 Aug 2025 02:26:32 +0000 (11:26 +0900)]
Doc: Update sample script links in "8.2. Pgpool-II + Watchdog Setup Example"

This is a follow-up to commit e138a18.
Updated the sample script links in section "8.2. Pgpool-II + Watchdog Setup Example" to point to the GitHub repository file URLs.

4 months agoFix a compiler warning introduced in commit 3cc3d2d.
Bo Peng [Fri, 25 Jul 2025 08:27:21 +0000 (17:27 +0900)]
Fix a compiler warning introduced in commit 3cc3d2d.

4 months agoFix watchdog to print inappropriate NOTICE message.
Tatsuo Ishii [Fri, 25 Jul 2025 04:55:42 +0000 (13:55 +0900)]
Fix watchdog to print inappropriate NOTICE message.

read_ipc_socket_and_process() printed a notice message every time when
it wrote commands to IPC socket even if it was successful. Fix this to
print the notice message only when the write failed.

The reason why this bug was not recognized is, the message appears
only when log_min_messages is set to notice or higher.

Discussion: https://github.com/pgpool/pgpool2/issues/121
Backpatch-through: v4.2

4 months agoDoc: unify watchdog leader terms (followup).
Tatsuo Ishii [Thu, 24 Jul 2025 01:07:29 +0000 (10:07 +0900)]
Doc: unify watchdog leader terms (followup).

This is a followup commit to 222a88a751c75acfc809e06559621699255921f7.

This commit updates advaced.sgml.

Backpatch-trhough: v4.2

4 months agoDoc: unify watchdog leader terms.
Tatsuo Ishii [Wed, 23 Jul 2025 06:51:56 +0000 (15:51 +0900)]
Doc: unify watchdog leader terms.

Previously terms "leader", "active" and "coordinator" were used to
mean the leader watchdog node.  This brought enough confusion. So this
commit unifies them to "leader"."

Backpatch-trhough: v4.2

4 months agoAdd function comment to is_wd_lifecheck_ready.
Tatsuo Ishii [Tue, 22 Jul 2025 07:48:45 +0000 (16:48 +0900)]
Add function comment to is_wd_lifecheck_ready.

Also clarify a debug message. Previous it stated that the reason for
the function returns WD_NG was that pgpool has not send hearbeat
yet. Actually the reason could be that pgpool has not received
hearbeat yet too.

4 months agoFix resource leak while reading startup packet.
Tatsuo Ishii [Sat, 19 Jul 2025 06:48:37 +0000 (15:48 +0900)]
Fix resource leak while reading startup packet.

Per Coverity.

Backpatch-through: v4.2

4 months agoFix double pfree in 1b63aeb31.
Tatsuo Ishii [Sat, 19 Jul 2025 06:26:30 +0000 (15:26 +0900)]
Fix double pfree in 1b63aeb31.

By an oversight, the commit could bring a double pfree situation.

4 months agoAdd a48d72c16 to .git-blame-ignore-revs.
Tatsuo Ishii [Fri, 18 Jul 2025 06:48:37 +0000 (15:48 +0900)]
Add a48d72c16 to .git-blame-ignore-revs.

4 months agoFix indentation.
Tatsuo Ishii [Fri, 18 Jul 2025 06:39:40 +0000 (15:39 +0900)]
Fix indentation.

Fix indentation by running pgindent.

4 months agoFix coding issue regarding shift operation.
Tatsuo Ishii [Fri, 18 Jul 2025 05:45:42 +0000 (14:45 +0900)]
Fix coding issue regarding shift operation.

Per Coverity.

4 months agoFix memory leak.
Tatsuo Ishii [Fri, 18 Jul 2025 05:40:14 +0000 (14:40 +0900)]
Fix memory leak.

Fix resource leak in pool_push_pending_data pointed out by Coverity.

Backpatch-through: v4.2

4 months agoAdd .git-blame-ignore-revs.
Tatsuo Ishii [Thu, 17 Jul 2025 10:22:49 +0000 (19:22 +0900)]
Add .git-blame-ignore-revs.

.git-blame-ignore-revs lists commits to be ignored by git blame
command. Any indentation fix commit using pgindent should be added to
the file. How to add an entry to the file is explained in the beginning
of the file.

Also add 468573ad3 to the file as the first entry.

4 months agoRun pgindent.
Tatsuo Ishii [Thu, 17 Jul 2025 10:15:48 +0000 (19:15 +0900)]
Run pgindent.

4 months agoFix method to run pgindent.
Tatsuo Ishii [Thu, 17 Jul 2025 09:54:13 +0000 (18:54 +0900)]
Fix method to run pgindent.

Commit fd190f7ea imported pgindent but the method explained in
README.pgpool was wrong. typedefs.list can be generated by using
PostgreSQL's find_typedef. So import find_typedef and remove
unnecessary files. Proper way to run pgindent is explained in
README.pgpool.

4 months agoFeature: Make online recovery database configurable
Bo Peng [Thu, 17 Jul 2025 05:31:02 +0000 (14:31 +0900)]
Feature: Make online recovery database configurable

Prior to version 4.6, the online recovery database was hardcoded to "template1".
This commit introduces a new configuration parameter, "recovery_database",
which allows users to specify the database used for online recovery.
The default value is "postgres".

4 months agoDoc: Fix example script link at master.
Taiki Koshino [Wed, 16 Jul 2025 05:27:47 +0000 (14:27 +0900)]
Doc: Fix example script link at master.

Modified the sample script in the section "8.2. Pgpool-II + Watchdog Setup Example"

4 months agoFeature: implement protocol version 3.2 BackendKeyData and query cancel message.
Tatsuo Ishii [Tue, 15 Jul 2025 05:30:47 +0000 (14:30 +0900)]
Feature: implement protocol version 3.2 BackendKeyData and query cancel message.

Starting from PostgreSQL 18, frontend/backend protocol has been
changed to 3.2. In the changes the BackendKeyData and query cancel
message are modified to allow variable length cancel key.

This commit implements the changes and now we can connect to
PostgreSQL frontend and backend using 3.2 protocol.

Example session is:
PGMAXPROTOCOLVERSION="3.2" psql -p 11000 test

Author: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://www.postgresql.org/message-id/20250714.155710.1706961744888449986.ishii%40postgresql.org

4 months agoFix bug with pcp_proc_info.
Tatsuo Ishii [Tue, 15 Jul 2025 02:01:11 +0000 (11:01 +0900)]
Fix bug with pcp_proc_info.

When pcp_proc_info was invoked without "-v" option, pcp_proc_info did
not print the "statement" field.  This was due to oversight in the
frontend side of the command: forgot to add one more format siring
"%s".

This bug was in only master branch: when some new fields were added to
pcp_proc_info.

Reported-by: Bo Peng <pengbo@sraoss.co.jp>
Author: Tatsuo Ishii <ishii@postgresql.org>

4 months agoDoc: fix documentation for enum parameters reported as strings
Taiki Koshino [Tue, 15 Jul 2025 00:16:37 +0000 (09:16 +0900)]
Doc: fix documentation for enum parameters reported as strings

Fix documentations for 6 parameters.
Japanese docs too.
"log_standby_delay"
"log_backend_messages"
"wd_lifecheck_method"
"memqcache_method"
"disable_load_balance_on_write"
"backend_clustering_mode"

4 months agoDoc: fix documentation for parameters that are not reflected by reload.
Taiki Koshino [Tue, 8 Jul 2025 06:06:36 +0000 (15:06 +0900)]
Doc: fix documentation for parameters that are not reflected by reload.

"authentication_timeout" and "memqcache_oiddir" is not reflected by reload.
The documentation is changed to "This parameter can only be set at server start.".
Japanese doc too.

4 months agoImport pgindent.
Tatsuo Ishii [Thu, 10 Jul 2025 11:04:06 +0000 (20:04 +0900)]
Import pgindent.

Import PostgreSQL's pgindent.

This commit not only imports PostgreSQL's pgindent, but generates the
important file: typedefs.list. For this purpose followings are added:

- README.pgpool: How to generate typedefs.list.

- doxygen.list: Pgpool-II's typedefs extracted by doxygen. Plus
  manually added typedefs that were not detected by doxygen.

- enums.list: Pgpool-II's enums manually extracted from source code.

- exclude_files: files that should not be touched pgindent.

- run_pgindent: handy script to run pgindent. Should be run at src
  directory.

- typedefs.list.PostgreSQL: PostgreSQL's typedefs. To prepare for that
   doxygen misses some typedefs.

- make_typedefs.list: handy script to generate typedefs.list.

4 months agoFeature: implement NegotiateProtocolVersion message.
Tatsuo Ishii [Wed, 9 Jul 2025 06:58:16 +0000 (15:58 +0900)]
Feature: implement NegotiateProtocolVersion message.

Implementing the message is necessary when frontend requests the
protocol version 3.2 (i.e. PostgreSQL 18+ or compatible clients),
while backend still only supports 3.0 (i.e. backend is PostgreSQL 17
or before).

This commit handles the message so that the message is forwarded from
backend to frontend when there's no connection cache exists.

If connection cache exists, pgpool sends the message, which has been
saved at the time when the connection cache was created, to frontend.

Note that the frontend/backend protocol 3.2 changes the BackendKeyData
message format, but it's not implemented in this commit yet. This
means that still pgpool cannot handle 3.2 protocol.

Discussion: https://www.postgresql.org/message-id/20250708.112133.1324153277751075866.ishii%40postgresql.org

4 months agoFix broken scram-sha-256 authentication on big-endian machies.
Bo Peng [Mon, 30 Jun 2025 02:52:28 +0000 (11:52 +0900)]
Fix broken scram-sha-256 authentication on big-endian machies.

When scram-sha-256 authentication is performed, a hash function
pg_sha_256_final is used. It was imported from PostgreSQL and it uses
preprocessor define WORDS_BIGENDIAN to judge host machine's
endianness. Although WORDS_BIGENDIAN should be defined while
configure, this part was missed when pg_sha_256_final (and others) was
imported from PostgreSQL. As a result, scram-sha-256 worked only in
little endian machines. This commit fixes the issue by adding
AC_C_BIGENDIAN macro to configure.ac.

Author: Tatsuo Ishii
Reported-by: Christoph Berg
Reviewed-by: pranavkaruvally
Discussion: https://github.com/pgpool/pgpool2/issues/106
Backpatch-through: v4.2

4 months agoTest: more fix to 038.pcp_commands regression test.
Tatsuo Ishii [Fri, 27 Jun 2025 06:50:33 +0000 (15:50 +0900)]
Test: more fix to 038.pcp_commands regression test.

Commit 04e09df17 was not enough fix. The test calls pcp_proc_info()
pgpool_adm function along with user name and password (in the test
password is the same string as user name). Problem is, the user name
is obtained from a user name that runs the test, and we use psql -a to
submit the SQL, which prints the user name. Of course the user name
can vary depending on the environment, and it makes the test fail.  To
fix the issue, run psql without -a option.

5 months agoTest: fix 038.pcp_commands regression test.
Tatsuo Ishii [Wed, 25 Jun 2025 10:32:32 +0000 (19:32 +0900)]
Test: fix 038.pcp_commands regression test.

The result of the test showed local host IP. Although the IP can be
either IPv4 or IPv6, the test script hadn't considered it. To fix
this, now test.sh converts IPv4 and IPv6 IP to "localhost".

5 months agoFeature: add pgpool_adm_pcp_proc_info.
Tatsuo Ishii [Tue, 24 Jun 2025 10:16:15 +0000 (19:16 +0900)]
Feature: add pgpool_adm_pcp_proc_info.

This commit adds new pgpool_adm extension function:
pcp_proc_info. Also add new fields: client_host, client_port and SQL
statement to pcp_proc_info and "show pool_pools". With these additions
now it is possible to track the relationship among clients of pgpool,
pgpool itself and PostgreSQL.

Moreover the commit allows to know what commands (statements) are last
executed by using pcp_proc_info. Previously it was not possible unless
looking into the pgpool log.

lipcp.so version is bumped from 2.0 to 2.1.

5 months agoFix source code typos.
Bo Peng [Mon, 23 Jun 2025 02:54:30 +0000 (11:54 +0900)]
Fix source code typos.

5 months agoDoc: fix load balance explanation missed logical replication mode.
Tatsuo Ishii [Wed, 18 Jun 2025 08:04:13 +0000 (17:04 +0900)]
Doc: fix load balance explanation missed logical replication mode.

Backpatch-through: v4.2

5 months agoDoc: enhance pcp_node_info document.
Bo Peng [Wed, 18 Jun 2025 09:12:13 +0000 (18:12 +0900)]
Doc: enhance pcp_node_info document.

Clarify that each backend_application_nameX must match the value specified
in the application_name of primary_conninfo to correctly display
"replication_state" and "replication_sync_state".

5 months agoEnhance lifecheck log.
Tatsuo Ishii [Sat, 14 Jun 2025 11:54:13 +0000 (20:54 +0900)]
Enhance lifecheck log.

Previously when wd_lifecheck_method = 'query', life checking prints
SQL without application name if "%a" is specified in
log_line_prefix. This commit add application_name "lifecheck_ping" to
make the log looks better.  Since this changes user visible behavior,
I do not apply this to stable branches.

Discussion: [pgpool-hackers: 4603] life check log is not nice
https://www.pgpool.net/pipermail/pgpool-hackers/2025-June/004604.html

5 months agoFix heartbeat device treatment.
Tatsuo Ishii [Sat, 14 Jun 2025 11:12:57 +0000 (20:12 +0900)]
Fix heartbeat device treatment.

wd_create_hb_recv_socket() and wd_create_hb_send_socket() called
setsockopt(2) with wrong argument.

struct ifreq i;
strlcpy(i.ifr_name, hb_if->if_name, sizeof(i.ifr_name));
if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, &i, sizeof(i)) == -1)
:

This is not quite correct since the 4th argument should be
just a null terminated string (device name), not struct ifreq.

Discussion: [pgpool-hackers: 4602] heartbeat and SO_BINDTODEVICE
https://www.pgpool.net/pipermail/pgpool-hackers/2025-May/004603.html
Backpatch-through: v4.6

5 months agoFix resource leak in hearbeat receiver process.
Tatsuo Ishii [Sat, 14 Jun 2025 07:15:59 +0000 (16:15 +0900)]
Fix resource leak in hearbeat receiver process.

Pointed out by Coverity.
Backpatch-through: v4.6

5 months agoRemove or downgrade inappropriate log messages at pgpool startup.
Tatsuo Ishii [Sat, 14 Jun 2025 06:13:30 +0000 (15:13 +0900)]
Remove or downgrade inappropriate log messages at pgpool startup.

- Log regarding total shared memory allocation size was redundant.
- Other logs were too verbose and downgraded to DEBUG1.