pgsql: Fix reorder buffer memory accounting for toast changes. - Mailing list pgsql-committers

From Amit Kapila
Subject pgsql: Fix reorder buffer memory accounting for toast changes.
Date
Msg-id E1mPeU7-0000Ej-I1@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix reorder buffer memory accounting for toast changes.

While processing toast changes in logical decoding, we rejigger the
tuple change to point to in-memory toast tuples instead to on-disk toast
tuples. And, to make sure the memory accounting is correct, we were
subtracting the old change size and then after re-computing the new tuple,
re-adding its size at the end. Now, if there is any error before we add
the new size, we will release the changes and that will update the
accounting info (subtracting the size from the counters). And we were
underflowing there which leads to an assertion failure in assert enabled
builds and wrong memory accounting in reorder buffer otherwise.

Author: Bertrand Drouvot
Reviewed-by: Amit Kapila
Backpatch-through: 13, where memory accounting was introduced
Discussion: https://postgr.es/m/92b0ee65-b8bd-e42d-c082-4f3f4bf12d34@amazon.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/58cf794ca68d90ea11888f200e0b74d01d0c7093

Modified Files
--------------
src/backend/replication/logical/reorderbuffer.c | 37 +++++++++++++++----------
1 file changed, 23 insertions(+), 14 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Fix error handling with threads on OOM in ECPG connection logic
Next
From: Etsuro Fujita
Date:
Subject: pgsql: Doc: Remove type information for import_generated in postgres-fd