pgpool2.git / summary / log / commit / refs

commit    a03079a11769c72ac34e05dcb91f36793333bcfa
Author:   Taiki Koshino <koshino@sraoss.co.jp>
Date:     Tue Sep 29 20:05:13 2026 +0000

    Report replication delay as -1 for down standby nodes
    
    SHOW POOL_NODES and pcp_node_info reported the last measured replication
    delay after a standby node became down or was detached. The value could
    be stale because replication delay cannot be measured for a down node.
    
    Report the delay as "-1" for a down standby in both commands.
    Keep the stored value unchanged to avoid treating an unmeasured delay
    as zero when the standby is attached again.
    
    Update the 003.failover regression test expectations for the new
    SHOW POOL_NODES output.
    
    Author: Taiki Koshino <koshino@sraoss.co.jp>
    Discussion: https://github.com/pgpool/pgpool2/issues/131


src/test/regression/tests/003.failover/create_expected.sql | 2 +- .../regression/tests/003.failover/create_expected_node0.sql | 2 +- src/tools/pcp/pcp_frontend_client.c | 7 ++++++- src/utils/pool_process_reporting.c | 10 +++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/test/regression/tests/003.failover/create_expected.sql b/src/test/regression/tests/003.failover/create_expected.sql index 598d98a61..2b1040b74 100644 --- a/src/test/regression/tests/003.failover/create_expected.sql +++ b/src/test/regression/tests/003.failover/create_expected.sql @@ -17,7 +17,7 @@ CREATE TEMP TABLE tmp ( INSERT INTO tmp VALUES ('0','localhost','11002','up','up','0.500000','primary','unknown','0','false','0','','','XXXX-XX-XX XX:XX:XX','s'), -('1','localhost','11003','down','down','0.500000','standby','unknown','0','false','0','','','XXXX-XX-XX XX:XX:XX','s'), +('1','localhost','11003','down','down','0.500000','standby','unknown','0','false','-1','','','XXXX-XX-XX XX:XX:XX','s'), ('0','localhost','11002','up','up','0.500000','main','main','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'), ('1','localhost','11003','down','down','0.500000','replica','replica','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'); diff --git a/src/test/regression/tests/003.failover/create_expected_node0.sql b/src/test/regression/tests/003.failover/create_expected_node0.sql index 676ad70ff..fc3a4c3d5 100644 --- a/src/test/regression/tests/003.failover/create_expected_node0.sql +++ b/src/test/regression/tests/003.failover/create_expected_node0.sql @@ -16,7 +16,7 @@ CREATE TEMP TABLE tmp ( mode text); INSERT INTO tmp VALUES -('0','localhost','11002','down','down','0.500000','standby','unknown','0','false','0','','','XXXX-XX-XX XX:XX:XX','s'), +('0','localhost','11002','down','down','0.500000','standby','unknown','0','false','-1','','','XXXX-XX-XX XX:XX:XX','s'), ('1','localhost','11003','up','up','0.500000','primary','unknown','0','false','0','','','XXXX-XX-XX XX:XX:XX','s'), ('0','localhost','11002','down','down','0.500000','replica','replica','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'), ('1','localhost','11003','up','up','0.500000','main','main','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'); diff --git a/src/tools/pcp/pcp_frontend_client.c b/src/tools/pcp/pcp_frontend_client.c index 928749d99..caf9703b2 100644 --- a/src/tools/pcp/pcp_frontend_client.c +++ b/src/tools/pcp/pcp_frontend_client.c @@ -564,7 +564,12 @@ output_nodeinfo_result(PCPResultInfo * pcpResInfo, bool all, bool verbose) localtime_r(&backend_info->status_changed_time, &tm); strftime(last_status_change, sizeof(last_status_change), "%F %T", &tm); - if (backend_info->standby_delay_by_time) + if (backend_info->role == ROLE_STANDBY && + backend_info->backend_status == CON_DOWN) + { + snprintf(standby_delay_str, sizeof(standby_delay_str), "-1"); + } + else if (backend_info->standby_delay_by_time) { snprintf(standby_delay_str, sizeof(standby_delay_str), "%.6f", ((float) backend_info->standby_delay) / 1000000); if (verbose) diff --git a/src/utils/pool_process_reporting.c b/src/utils/pool_process_reporting.c index 3fa073f09..da3064359 100644 --- a/src/utils/pool_process_reporting.c +++ b/src/utils/pool_process_reporting.c @@ -1437,7 +1437,15 @@ get_nodes(int *nrows, int node_id) { snprintf(nodes[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "standby"); - if (bi->standby_delay_by_time) + /* + * Report "-1" if the replication delay cannot be measured; + * otherwise, report the last measured value. + */ + if (!VALID_BACKEND_RAW(i)) + { + snprintf(nodes[i].delay, POOLCONFIG_MAXWEIGHTLEN, "-1"); + } + else if (bi->standby_delay_by_time) { snprintf(nodes[i].delay, POOLCONFIG_MAXWEIGHTLEN, "%.6f", ((float) bi->standby_delay) / 1000000); if (bi->standby_delay >= 2 * 1000 * 1000) [parent: a76292e80f38]