From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow decoding at prepare time in ReorderBuffer.
Date: Mon, 04 Jan 2021 03:13:53 +0000
Message-ID: <E1kwGJd-0003vT-V6@gemulon.postgresql.org> (raw)
Allow decoding at prepare time in ReorderBuffer.
This patch allows PREPARE-time decoding of two-phase transactions (if the
output plugin supports this capability), in which case the transactions
are replayed at PREPARE and then committed later when COMMIT PREPARED
arrives.
Now that we decode the changes before the commit, the concurrent aborts
may cause failures when the output plugin consults catalogs (both system
and user-defined).
We detect such failures with a special sqlerrcode
ERRCODE_TRANSACTION_ROLLBACK introduced by commit 7259736a6e and stop
decoding the remaining changes. Then we rollback the changes when rollback
prepared is encountered.
Author: Ajin Cherian and Amit Kapila based on previous work by Nikhil Sontakke and Stas Kelvich
Reviewed-by: Amit Kapila, Peter Smith, Sawada Masahiko, Arseny Sher, and Dilip Kumar
Tested-by: Takamichi Osumi
Discussion:
https://postgr.es/m/02DA5F5E-CECE-4D9C-8B4B-418077E2C010@postgrespro.ruhttps://postgr.es/m/CAMGcDxeqEpWj3fTXwqhSwBdXd2RS9jzwWscO-XbeCfso6ts3+Q@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a271a1b50e9bec07e2ef3a05e38e7285113e4ce6
Modified Files
--------------
contrib/test_decoding/Makefile | 2 +-
contrib/test_decoding/expected/twophase.out | 235 +++++++++++
contrib/test_decoding/expected/twophase_stream.out | 147 +++++++
contrib/test_decoding/sql/twophase.sql | 112 ++++++
contrib/test_decoding/sql/twophase_stream.sql | 45 +++
doc/src/sgml/logicaldecoding.sgml | 104 ++++-
src/backend/replication/logical/decode.c | 286 ++++++++++++--
src/backend/replication/logical/logical.c | 9 -
src/backend/replication/logical/reorderbuffer.c | 432 +++++++++++++++++----
src/backend/replication/logical/snapbuild.c | 7 +
src/include/replication/reorderbuffer.h | 33 +-
11 files changed, 1296 insertions(+), 116 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: akapila@postgresql.org
Subject: Re: pgsql: Allow decoding at prepare time in ReorderBuffer.
In-Reply-To: <E1kwGJd-0003vT-V6@gemulon.postgresql.org>
References: <E1kwGJd-0003vT-V6@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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