| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix stalled lag columns in pg_stat_replication when replay LSN s |
| Date: | 2025-10-22 02:30:26 |
| Message-ID: | E1vBOcM-002swc-1N@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix stalled lag columns in pg_stat_replication when replay LSN stops advancing.
Previously, when the replay LSN reported in feedback messages from a standby
stopped advancing, for example, due to a recovery conflict, the write_lag and
flush_lag columns in pg_stat_replication would initially update but then stop
progressing. This prevented users from correctly monitoring replication lag.
The problem occurred because when any LSN stopped updating, the lag tracker's
cyclic buffer became full (the write head reached the slowest read head).
In that state, the lag tracker could no longer compute round-trip lag values
correctly.
This commit fixes the issue by handling the slowest read entry (the one
causing the buffer to fill) as a separate overflow entry and freeing space
so the write and other read heads can continue advancing in the buffer.
As a result, write_lag and flush_lag now continue updating even if the reported
replay LSN remains stalled.
Backpatch to all supported versions.
Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Chao Li <lic(at)highgo(dot)com>
Reviewed-by: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>
Reviewed-by: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAHGQGwGdGQ=1-X-71Caee-LREBUXSzyohkoQJd4yZZCMt24C0g@mail.gmail.com
Backpatch-through: 13
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/9670032cc51f502e39b4b99eba72dd14573d3776
Modified Files
--------------
src/backend/replication/walsender.c | 50 ++++++++++++++++++++++++-------------
1 file changed, 33 insertions(+), 17 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2025-10-22 02:30:46 | pgsql: Fix stalled lag columns in pg_stat_replication when replay LSN s |
| Previous Message | Fujii Masao | 2025-10-22 02:29:57 | pgsql: Fix stalled lag columns in pg_stat_replication when replay LSN s |