| From: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
|---|---|
| To: | pgpool-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgpool: Keep local primary_node_id when leader watchdog reports the ini |
| Date: | 2026-05-19 12:49:21 |
| Message-ID: | E1wPJsv-00DM4e-0H@gothos.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgpool-committers |
Keep local primary_node_id when leader watchdog reports the initial -2 sentinel.
When all pgpool nodes in a cluster are stopped and started simultaneously
(e.g. via an admin "restart all pgpool nodes" action), every node initializes
Req_info->primary_node_id to -2 (the sentinel) and then runs
find_primary_node_repeatedly() locally to discover the real primary. The
watchdog elects a LEADER in parallel; the losing nodes transition to STANDBY,
receive SIG_WATCHDOG_STATE_CHANGED, and call sync_backend_from_watchdog() to
pull the leader's view.
If the leader's own find_primary_node_repeatedly() has not finished yet, the
leader serializes its still-uninitialized primary_node_id (-2) and the
standby's existing protective branch only covers -1 (quarantine). The -2
falls through to the else-clause and overwrites the standby's freshly-
determined valid primary_node_id with -2.
sync_backend_from_watchdog() is only re-invoked on SIG_BACKEND_SYNC_REQUIRED,
which is raised only on WD_FAILOVER_END. No subsequent event fires after a
simultaneous restart, so the standby is stuck at -2 indefinitely.
Add a guard that keeps the local primary_node_id when the leader's value is
the -2 initial sentinel.
Reported-by: Emond Papegaaij <emond(dot)papegaaij(at)gmail(dot)com>
Reported-by: Claude Code
Author: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Discussion: https://www.postgresql.org/message-id/CAGXsc%2BZmBoLs3Mz%3DG-Bdm4JJG%2BfH1NpHfR3qVJVwW4eBKWwStQ%40mail.gmail.com
Backpatch-through: v4.3
Branch
------
V4_5_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=bd27378c2c9ac8d1a511f10bf7b8d4708f7b6980
Modified Files
--------------
src/main/pgpool_main.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuo Ishii | 2026-05-19 12:49:27 | pgpool: Keep local primary_node_id when leader watchdog reports the ini |
| Previous Message | Tatsuo Ishii | 2026-05-19 12:49:15 | pgpool: Keep local primary_node_id when leader watchdog reports the ini |