pgsql: Fix memory counter update in ReorderBuffer. - Mailing list pgsql-committers

From Masahiko Sawada
Subject pgsql: Fix memory counter update in ReorderBuffer.
Date
Msg-id E1sie1Q-001bBW-II@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Masahiko Sawada
Date:
Subject: pgsql: Fix memory counter update in ReorderBuffer.
Next
From: Masahiko Sawada
Date:
Subject: Re: pgsql: Restrict accesses to non-system views and foreign tables during