| From: | Rajesh Kumar Thandapani <rajeshkumarth(at)google(dot)com> |
|---|---|
| To: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Ajin Cherian <itsajin(at)gmail(dot)com> |
| Subject: | Re: Add aborted_txns and aborted_bytes to pg_stat_replication_slots |
| Date: | 2026-12-04 15:55:05 |
| Message-ID: | CAJoZ81suDoL-r+aZFNN_X+_4mjW+=GbGFYoZEUbikQZ7YgtO4g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, 4 Dec 2026 at 08:29 UTC, Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
> Can you clarify how DBAs use these attributes? According to the cheat sheet on
> the wikipage [1], pg_stat_replication_slot can be checked to check to check amount
> of spilled or streamed changes. For this usage, I felt current information
> might be enough because xxx_bytes can be increased even for ABORT.
>
> [1]: https://wiki.postgresql.org/wiki/Operations_cheat_sheet#:~:text=logical_decoding_work_mem
Hi Hayato,
Thanks for taking a look and raising this question.
For the basic case of checking whether a slot is spilling or streaming, I agree
that spill_bytes and stream_bytes already cover transactions that exceed
logical_decoding_work_mem. There are a few operational cases where those
counters are not enough on their own:
1. Aborted transactions that stay below logical_decoding_work_mem, or get
truncated early once the abort is already visible in CLOG, do not increment
spill_bytes, stream_bytes, or total_bytes at all. If an application hits a
retry loop, deadlocks, or statement timeouts on medium-sized write transactions
(say 10-50 MB with a 64 MB logical_decoding_work_mem), walsender still has to
read, decode, and buffer all of that WAL, causing replication lag and CPU usage
while every existing counter in pg_stat_replication_slots stays flat.
2. Even when spill_bytes or stream_bytes does grow, DBAs still need to tell
whether the pressure comes from normal large committed transactions or from
rolled-back work (such as failed bulk loads or aborted two-phase transactions).
Those point to different fixes: raising logical_decoding_work_mem makes sense
for large committed transactions, whereas if most of the spilled or streamed
volume is coming from aborts, increasing logical_decoding_work_mem just lets
rolled-back transactions hold more memory while the real fix is addressing the
failing workload on the publisher.
3. With streaming enabled, a streamed transaction increments stream_bytes and
total_bytes even if it eventually aborts. Having aborted_txns and aborted_bytes
alongside them lets DBAs see how much of the streamed replication traffic (and
apply worker work on the subscriber) ended up wasted on aborts.
4. pg_stat_database.xact_rollback does not really fill this gap because it is
database-wide, counts small read-only rollbacks the same as multi-GB failed
writes, and has no byte count or per-slot breakdown.
If this makes sense, I would also be happy to expand the monitoring.sgml
descriptions a bit so this usage is clearer in the docs.
Regards,
Rajesh Kumar Thandapani
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayoub Kazar | 2026-12-04 15:58:02 | Re: Propagate LIMIT bound through the outer side of left join |
| Previous Message | Nathan Bossart | 2026-12-04 15:54:07 | Re: add --transfer-mode to pg_upgrade |