[pgpool-hackers: 4364] Fix bug in find_primary_node_repeatedly()

Bo Peng pengbo at sraoss.co.jp
Fri Aug 4 14:31:18 JST 2023


I found a bug that find_primary_node_repeatedly() doesn't terminate within search_primary_node_timeout.

Pgpool-II was looking for primary node every second, below is the code:

    for (sec = 0; (pool_config->search_primary_node_timeout == 0 ||
                   sec < pool_config->search_primary_node_timeout); sec++)
    {
        node_id = find_primary_node();
        if (node_id != -1)
            break;
        pool_sleep(1);
    }

If the error is returned immediately, there is no problem,
but in the case of a network failure, it will take longer than the value set in "search_primary_node_timeout".

This commit fixed this problem:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=7db55fa23dec0c10099459fb28d1108746835879

This commit also fixed an unnecessary connection retry.

-- 
Bo Peng <pengbo at sraoss.co.jp>
SRA OSS LLC
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/


More information about the pgpool-hackers mailing list