pgsql: Fix decoding of speculative aborts.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix decoding of speculative aborts.
Date: 2021-06-15 03:56:23
Message-ID: E1lt0Bb-0005ye-SC@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix decoding of speculative aborts.

During decoding for speculative inserts, we were relying for cleaning
toast hash on confirmation records or next change records. But that
could lead to multiple problems (a) memory leak if there is neither a
confirmation record nor any other record after toast insertion for a
speculative insert in the transaction, (b) error and assertion failures
if the next operation is not an insert/update on the same table.

The fix is to start queuing spec abort change and clean up toast hash
and change record during its processing. Currently, we are queuing the
spec aborts for both toast and main table even though we perform cleanup
while processing the main table's spec abort record. Later, if we have a
way to distinguish between the spec abort record of toast and the main
table, we can avoid queuing the change for spec aborts of toast tables.

Reported-by: Ashutosh Bapat
Author: Dilip Kumar
Reviewed-by: Amit Kapila
Backpatch-through: 9.6, where it was introduced
Discussion: https://postgr.es/m/CAExHW5sPKF-Oovx_qZe4p5oM6Dvof7_P+XgsNAViug15Fm99jA@mail.gmail.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/602a32a685e4ca715a996f899d906e5f24308b51

Modified Files
--------------
src/backend/replication/logical/decode.c | 14 +++----
src/backend/replication/logical/reorderbuffer.c | 49 +++++++++++++++++++------
src/include/replication/reorderbuffer.h | 9 +++--
3 files changed, 48 insertions(+), 24 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2021-06-15 12:59:41 pgsql: Support for unnest(multirange) and cast multirange as an array o
Previous Message Tom Lane 2021-06-15 01:58:39 pgsql: Update variant expected-result file.