pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Masahiko Sawada <msawada@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix memory counter update in ReorderBuffer.
Date: Mon, 26 Aug 2024 18:00:51 +0000
Message-ID: <E1sie1L-001bAv-LY@gemulon.postgresql.org> (raw)

Fix memory counter update in ReorderBuffer.

Commit 5bec1d6bc5e changed the memory usage updates of the
ReorderBufferTXN to zero all at once by subtracting txn->size, rather
than updating it for each change. However, if TOAST reconstruction
data remained in the transaction when freeing it, there were cases
where it further subtracted the memory counter from zero, resulting in
an assertion failure.

This change calculates the memory size for each change and updates the
memory usage to precisely the amount that has been freed.

Backpatch to v17, where this was introducd.

Reviewed-by: Amit Kapila, Shlok Kyal
Discussion: https://postgr.es/m/CAD21AoAqkNUvicgKPT_dXzNoOwpPkVTg0QPPxEcWmzT0moCJ1g%40mail.gmail.com
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/dbed2e36625de9d4074243f60f48e04b5ed67810

Modified Files
--------------
contrib/test_decoding/expected/stream.out       | 19 +++++++++++++++
contrib/test_decoding/sql/stream.sql            | 15 ++++++++++++
src/backend/replication/logical/reorderbuffer.c | 32 +++++++++++++++++++++----
3 files changed, 62 insertions(+), 4 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1sie1L-001bAv-LY@gemulon.postgresql.org>
Permalink:  ../E1sie1L-001bAv-LY@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sie1L-001bAv-LY@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: msawada@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix memory counter update in ReorderBuffer.
  In-Reply-To: <E1sie1L-001bAv-LY@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox