[pgpool-committers: 9054] pgpool: Fix integer overflow in streaming replication check.

Tatsuo Ishii ishii at sraoss.co.jp
Fri Jan 13 10:31:45 JST 2023


Fix integer overflow in streaming replication check.

When delay_threshold_by_time is enabled, following query is
periodically sent to the primary node to obtain the replication delay
in micro seconds.

SELECT application_name, state, sync_state,(EXTRACT(EPOCH FROM
replay_lag)*1000000)::integer FROM pg_stat_replication";

Unfortunately the result from EXTRACT::integer overflows if replay_lag
is bigger than 2147483647/1000000 (that is about 35 minutes and 47
seconds). Fix is, changing "integer" to "bigint". By this, the result
will not overflow unless it becomes bigger than 292,472 years.
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2023-January/008600.html
Backpatch-through: 4.4

Branch
------
V4_4_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=ac752fd6808aab4a33ab0968751bb9a9b83e49e5

Modified Files
--------------
src/streaming_replication/pool_worker_child.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



More information about the pgpool-committers mailing list