pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix memory counter update in ReorderBuffer.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix memory counter update in ReorderBuffer.
@ 2024-08-26 18:00  Masahiko Sawada <msawada@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Masahiko Sawada @ 2024-08-26 18:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix memory counter update in ReorderBuffer.
@ 2024-08-26 18:00  Masahiko Sawada <msawada@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Masahiko Sawada @ 2024-08-26 18:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/52f1d6730bf7132a175b9b612029812859218927

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-08-26 18:00 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-08-26 18:00 pgsql: Fix memory counter update in ReorderBuffer. Masahiko Sawada <msawada@postgresql.org>
2024-08-26 18:00 pgsql: Fix memory counter update in ReorderBuffer. Masahiko Sawada <msawada@postgresql.org>

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