Re: BUG #18241: PushTransaction may cause Standby to execute ItemIdMarkDead

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: feichanghong@qq.com, pgsql-bugs@lists.postgresql.org
Date: 2023-12-12T08:57:01Z
Lists: pgsql-bugs

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Prevent tuples to be marked as dead in subtransactions on standbys

  2. Allow read only connections during recovery, known as Hot Standby.

On Tue, Dec 12, 2023 at 01:49:00PM +0900, Kyotaro Horiguchi wrote:
> This appears to be a bug that has existed for a long time since commit
> efc16ea520 (in 2009). Your fix looks correct to me, but as for me, the
> comment is not particularly necessary, and it would be sufficient to
> insert the new line in the location according to the member order
> within TransactionStateData.

Oops.  It's surprising that this has never been diagnosed but at the
same time I don't really see subtransactions being a common pattern in
a read-only workload for a standby, and it can easily cause MVCC
issues by removing tuples too eagerly and a standby may still need
them.  An issue if that this could cause problems if you do catalog
scans, which may explain a few bugs I recall seeing over the years,
even if these did not directly mention the use of ssavepoints.  I'd
need to double-check the archives.  If going through a driver layer
like the ODBC driver that enforces savepoints for each query, that
would be bad. 

Your fix sounds good to me (no need for a comment), I'll take care of
it after looking a bit more at the area.
--
Michael