From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
---|---|
To: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
Cc: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Add memory_limit_hits to pg_stat_replication_slots |
Date: | 2025-10-03 13:15:16 |
Message-ID: | aN/MZF9zlhcIt4YK@ip-10-97-1-34.eu-west-3.compute.internal |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On Fri, Oct 03, 2025 at 05:19:42PM +0530, Ashutosh Bapat wrote:
> + bool memory_limit_reached = (rb->size >= logical_decoding_work_mem *
> (Size) 1024);
> +
> + if (memory_limit_reached)
> + rb->memExceededCount += 1;
Thanks for looking at it!
> If the memory limit is hit but no transaction was serialized, the
> stats won't be updated since UpdateDecodingStats() won't be called. We
> need to call UpdateDecodingStats() in ReorderBufferCheckMemoryLimit()
> if no transaction was streamed or spilled.
I did some testing and the stats are reported because UpdateDecodingStats() is
also called in DecodeCommit(), DecodeAbort() and DecodePrepare() (in addition
to ReorderBufferSerializeTXN() and ReorderBufferStreamTXN()). That's also why
,for example, total_txns is reported even if no transaction was streamed or
spilled.
> -SELECT slot_name, spill_txns, spill_count FROM
> pg_stat_replication_slots WHERE slot_name =
> 'regression_slot_stats4_twophase';
> - slot_name | spill_txns | spill_count
> ----------------------------------+------------+-------------
> - regression_slot_stats4_twophase | 0 | 0
> +SELECT slot_name, spill_txns, spill_count, mem_exceeded_count FROM
> pg_stat_replication_slots WHERE slot_name =
> 'regression_slot_stats4_twophase';
> + slot_name | spill_txns | spill_count |
> mem_exceeded_count
> +---------------------------------+------------+-------------+--------------------
> + regression_slot_stats4_twophase | 0 | 0 |
> 1
> (1 row)
>
> Are we sure that mem_exceeded_count will always be 1 in this case? Can
> it be 2 or more because of background activity?
I think that the question could be the same for spill_txns and spill_count. It
seems to have been working fine (that way) since this test exists (added in
072ee847ad4c) but I think that you raised a good point.
Sawada-San, what do you think about this particular test, is it safe to rely
on the exact values here?
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Burd | 2025-10-03 13:29:09 | Re: Fixing a few minor misusages of bms_union() |
Previous Message | jian he | 2025-10-03 12:56:53 | Re: sql/json query function JsonBehavior default expression's collation may differ from returning type's collation |