pgsql: Fix ReorderBuffer memory overflow check. - Mailing list pgsql-committers

From Amit Kapila
Subject pgsql: Fix ReorderBuffer memory overflow check.
Date
Msg-id E1jit4x-0005KJ-9l@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix ReorderBuffer memory overflow check.

Commit cec2edfa78 introduced logical_decoding_work_mem to limit
ReorderBuffer memory usage. We spill the changes once the memory occupied
by changes exceeds logical_decoding_work_mem.  There was an assumption
in the code that by evicting the largest (sub)transaction we will come
under the memory limit as the selected transaction will be at least as
large as the most recent change (which caused us to go over the memory
limit).  However, that is not true because a user can reduce the
logical_decoding_work_mem to a smaller value before the most recent
change.

We fix it by allowing to evict the transactions until we reach under the
memory limit.

Reported-by: Fujii Masao
Author: Amit Kapila
Reviewed-by: Fujii Masao
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/2b7ba291-22e0-a187-d167-9e5309a3458d@oss.nttdata.com

Branch
------
master

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

Modified Files
--------------
src/backend/replication/logical/reorderbuffer.c | 54 +++++++++++++------------
1 file changed, 29 insertions(+), 25 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Spelling adjustments
Next
From: Peter Eisentraut
Date:
Subject: pgsql: Update description of parameter password_encryption