From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Nikhil Sontakke <nikhils@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: Craig Ringer <craig@2ndquadrant.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Cc: Sokolov Yura <y.sokolov@postgrespro.ru>
Cc: Stas Kelvich <s.kelvich@postgrespro.ru>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Re: [HACKERS] logical decoding of two-phase transactions
Date: Tue, 3 Apr 2018 16:59:27 +0200
Message-ID: <782517ca-1e99-06fe-eba9-34f826118289@2ndquadrant.com> (raw)
In-Reply-To: <CAMGcDxchx=0PeQBVLzrgYG2AQ49QSRxHj5DCp7yy0QrJR0S0nA@mail.gmail.com>
References: <CAMsr+YEb-f1oG+1wGji_sgswRsVQYtVXuTbVH=nnY6thMfiCqA@mail.gmail.com>
<CAMGcDxcD2fWqUwiPWGL_d-ie-CoGTVFAsgQvQ91H93q2Jc-mhA@mail.gmail.com>
<CAMGcDxf9HHmDOti4-DSQTtGo48R4OMki+BktPn2uTOtGr4XomQ@mail.gmail.com>
<c167340c-0751-d54b-0f32-fa83fd414863@2ndquadrant.com>
<CAMGcDxcGtRXtF1r3VqddzHba+BTm7q8wbgEsyhmOFuDckMTZFQ@mail.gmail.com>
<dd5a9cb7-bb10-cb5c-834e-08dc3ffc057f@2ndquadrant.com>
<20180329215815.36xxakgujx4luo4m@alap3.anarazel.de>
<0925358a-e11d-51bc-c3c1-959ded75f604@2ndquadrant.com>
<20180329222441.xxo2zxkjydpgjs4n@alap3.anarazel.de>
<CANP8+jLZy6Pxqp2Vxo20OuR5v_B1hEywR6Hp7DHwNn6Yi3B-Dw@mail.gmail.com>
<20180402180451.ip3uuvadhgxjvefo@alap3.anarazel.de>
<CAMGcDxchx=0PeQBVLzrgYG2AQ49QSRxHj5DCp7yy0QrJR0S0nA@mail.gmail.com>
FWIW, a couple of additional comments based on eyeballing the diffs:
1) twophase.c
---------
I think this comment is slightly inaccurate:
/*
* Coordinate with logical decoding backends that may be already
* decoding this prepared transaction. When aborting a transaction,
* we need to wait for all of them to leave the decoding group. If
* committing, we simply remove all members from the group.
*/
Strictly speaking, we're not waiting for the workers to leave the
decoding group, but to set decodeLocked=false. That is, we may proceed
when there still are members, but they must be in unlocked state.
2) reorderbuffer.c
------------------
I've already said it before, I find the "flags" bitmask and rbtxn_*
macros way less readable than individual boolean flags. It was claimed
this was done on Andres' request, but I don't see that in the thread. I
admit it's rather subjective, though.
I see ReorederBuffer only does the lock/unlock around apply_change and
RelationIdGetRelation. That seems insufficient - RelidByRelfilenode can
do heap_open on pg_class, for example. And I guess we need to protect
rb->message too, because who knows what the plugin does in the callback?
Also, we should not allocate gid[GIDSIZE] for every transaction. For
example subxacts never need it, and it seems rather wasteful to allocate
200B when the rest of the struct has only ~100B. This is particularly
problematic considering ReorderBufferTXN is not spilled to disk when
reaching the memory limit. It needs to be allocated ad-hoc only when
actually needed.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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-hackers@postgresql.org
Cc: tomas.vondra@2ndquadrant.com, nikhils@2ndquadrant.com, andres@anarazel.de, simon@2ndquadrant.com, craig@2ndquadrant.com, peter.eisentraut@2ndquadrant.com, petr.jelinek@2ndquadrant.com, y.sokolov@postgrespro.ru, s.kelvich@postgrespro.ru, 9erthalion6@gmail.com, tgl@sss.pgh.pa.us, sawada.mshk@gmail.com, robertmhaas@gmail.com
Subject: Re: [HACKERS] logical decoding of two-phase transactions
In-Reply-To: <782517ca-1e99-06fe-eba9-34f826118289@2ndquadrant.com>
References: <CAMsr+YEb-f1oG+1wGji_sgswRsVQYtVXuTbVH=nnY6thMfiCqA@mail.gmail.com> <CAMGcDxcD2fWqUwiPWGL_d-ie-CoGTVFAsgQvQ91H93q2Jc-mhA@mail.gmail.com> <CAMGcDxf9HHmDOti4-DSQTtGo48R4OMki+BktPn2uTOtGr4XomQ@mail.gmail.com> <c167340c-0751-d54b-0f32-fa83fd414863@2ndquadrant.com> <CAMGcDxcGtRXtF1r3VqddzHba+BTm7q8wbgEsyhmOFuDckMTZFQ@mail.gmail.com> <dd5a9cb7-bb10-cb5c-834e-08dc3ffc057f@2ndquadrant.com> <20180329215815.36xxakgujx4luo4m@alap3.anarazel.de> <0925358a-e11d-51bc-c3c1-959ded75f604@2ndquadrant.com> <20180329222441.xxo2zxkjydpgjs4n@alap3.anarazel.de> <CANP8+jLZy6Pxqp2Vxo20OuR5v_B1hEywR6Hp7DHwNn6Yi3B-Dw@mail.gmail.com> <20180402180451.ip3uuvadhgxjvefo@alap3.anarazel.de> <CAMGcDxchx=0PeQBVLzrgYG2AQ49QSRxHj5DCp7yy0QrJR0S0nA@mail.gmail.com> <782517ca-1e99-06fe-eba9-34f826118289@2ndquadrant.com>
* 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