Re: Logical Decoding and HeapTupleSatisfiesVacuum assumptions

From: Nikhil Sontakke <nikhils(at)2ndquadrant(dot)com>
To: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Logical Decoding and HeapTupleSatisfiesVacuum assumptions
Date: 2018-01-29 07:15:04
Message-ID: CAMGcDxd14Z=_iqJ-fYMw9riEtGZwE7YgjvQOv++taEegebQvig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> Having this as responsibility of plugin sounds interesting. It certainly
> narrows the scope for which we need to solve the abort issue. For 2PC
> that may be okay as we need to somehow interact with transaction manager
> as Simon noted. I am not sure if this helps streaming use-case though as
> there is not going to be any external transaction management involved there.
>
> In any case all this interlocking could potentially be made less
> impact-full by only doing it when we know the transaction did catalog
> changes prior to currently decoded change (which we do during decoding)
> since that's the only time we are interested in if it aborted or not.
>
> This all leads me to another idea. What if logical decoding provided API
> for "locking/unlocking" the currently decoded transaction against abort.
> This function would then be called by both decoding and output plugin
> before any catalog read. The function can be smart enough to be NOOP if
> the transaction is not running (ie we are not doing 2PC decoding or
> streaming) or when the transaction didn't do any catalog modifications
> (we already have that info easily accessible as bool).
>
> That would mean we'd never do any kind of heavy locking for prolonged
> periods of time (ie network calls) but only during catalog access and
> only when needed. It would also solve this for both 2PC and streaming
> and it would be easy to use by plugin authors. Just document that some
> call should be done before catalog access when in output plugin, can
> even be Asserted that the call was done probably.
>
> Thoughts?
>

Yeah, this might work. We already have SET_LOCKTAG_TRANSACTION() via
which every transaction takes an exclusive lock on its own
transactionid when it starts, for example. We ideally want a single
solution to handle 2PC and ongoing (streaming) transactions. We could
introduce a new SET_LOCKTAG_LOGICALTRANSACTION(). The logical decoding
process could take a SHARED lock on this, check if the XID is still ok
to decode, read the catalog and unlock. Abort/Commit transaction
processing could take this in EXCLUSIVE mode.

As mentioned above, the plugin API which takes this lock will be smart
enough to be a NOOP if the transaction is not running (i.e we are not
doing 2PC decoding or streaming) or when the transaction didn't do any
catalog modifications.

Thoughts?

Regards,
Nikhils
--
Nikhil Sontakke http://www.2ndQuadrant.com/
PostgreSQL/Postgres-XL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2018-01-29 07:25:49 Re: Query related to alter table ... attach partition
Previous Message Masahiko Sawada 2018-01-29 07:12:41 Re: [HACKERS] [PATCH] Vacuum: Update FSM more frequently