pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: James Stuart <slim2k@privatejuris.org>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Can two-phase commit support LISTEN, UNLISTEN, and NOTIFY?
Date: Sat, 16 Sep 2023 19:03:05 -0400
Message-ID: <3978033.1694905385@sss.pgh.pa.us> (raw)
In-Reply-To: <f31290e4-7d3e-4784-252d-2f1863301522@privatejuris.org>
References: <f31290e4-7d3e-4784-252d-2f1863301522@privatejuris.org>

James Stuart <slim2k@privatejuris.org> writes:
> Can you please clarify, is lack of support for "LISTEN, UNLISTEN, and 
> NOTIFY" with two-phase commits an architecture limitation or is this 
> lacking implementation?

The point of LISTEN and UNLISTEN is to change the listening state of
the current session, so it's hard to see how it'd make sense to
decouple them into a prepared transaction that might get committed by
a different session.  That'd end up with that other session changing
listen state (barring some really messy mechanism for propagating
the change back to the original session, assuming it still exists);
which seems surprising and probably not very useful.

I suppose you could argue that NOTIFY is a fire-and-forget operation
that could be postponed into a prepared transaction without making
a semantic mess.  But even then, it's not very clear whether the
message ought to carry the PID of the original session or the
committing session.  The original session would make more sense,
were it not that that might not exist anymore (and indeed its PID
could now be in use by some unrelated process).

Another problem, which perhaps is an implementation detail but
is real nonetheless, is that the current NOTIFY logic goes out
of its way to ensure that NOTIFY cannot cause a post-commit failure.
It does that by pushing the pending NOTIFY message(s) into the shared
queue before we reach the point of atomic commit.  If we run out of
space in the notify queue we can still fail the current transaction.
This approach is dependent on the assumption that it won't be very
long from pushing the messages into the queue to actual commit, else
we run the risk of clogging the queue.  So we couldn't perform that
step during PREPARE, and then there's a problem that we've created a
way for COMMIT PREPARED to fail, which ideally it should never do.

So I think there are indeed semantic issues, it's not entirely
a matter of "nobody got around to it".

			regards, tom lane





view thread (2+ messages)

Message-ID: <3978033.1694905385@sss.pgh.pa.us>
Permalink:  ../3978033.1694905385@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3978033.1694905385@sss.pgh.pa.us

 · 

reply

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, slim2k@privatejuris.org
  Subject: Re: Can two-phase commit support LISTEN, UNLISTEN, and NOTIFY?
  In-Reply-To: <3978033.1694905385@sss.pgh.pa.us>
  References: <f31290e4-7d3e-4784-252d-2f1863301522@privatejuris.org> <3978033.1694905385@sss.pgh.pa.us>

* 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