pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Nikhil Sontakke <nikhils@2ndquadrant.com>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: StandbyRecoverPreparedTransactions recovers subtrans links incorrectly
Date: Wed, 26 Apr 2017 10:28:46 -0400
Message-ID: <2049.1493216926@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMGcDxfLxpb4iTQVeeJ3s=r4ZEtaHS5L4f_gj8CZtJ_69PcBzw@mail.gmail.com>
References: <20110.1492905318@sss.pgh.pa.us>
	<20170423001931.wk4os4x6dwtdfwgd@alap3.anarazel.de>
	<CANP8+jLy1VdopsdCi3c0=msJCfu-oHAhgPJgtKJ84fFN_8EmOw@mail.gmail.com>
	<20170423232504.o454vbowwvivkuyn@alap3.anarazel.de>
	<CANP8+j+vcrgv6-KaY_1bdgF7nE2G0r12c398g=7QyazVXem3xg@mail.gmail.com>
	<20170424185944.bjpb3yizeybv75hd@alap3.anarazel.de>
	<CANP8+jLcfoCsJb8R57=haWVJewiAkGixpY6MaN-TNpNiaLTnYg@mail.gmail.com>
	<CAMGcDxfLxpb4iTQVeeJ3s=r4ZEtaHS5L4f_gj8CZtJ_69PcBzw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Nikhil Sontakke <nikhils@2ndquadrant.com> writes:
> A SELECT query on the newly promoted master on any of the tables involved
> in the 2PC hangs. The hang is due to a loop in
> SubTransGetTopmostTransaction(). Due to incorrect linkages, we get a
> circular reference in parentxid <-> subxid inducing the infinite loop.

I'm inclined to propose that

(1) SubTransSetParent should contain an assert that 
	Assert(TransactionIdFollows(xid, parent));
There is a similar assertion near one of the call sites, but that's
obviously too far away from the action.

(2) SubTransGetTopmostTransaction ought to contain an actual runtime
test and ereport (not just Assert) that the parent XID it got from
pg_subtrans precedes the child XID that was looked up.  This would
protect us against similar infinite loops in the future.  Even without
bugs, such a loop could arise due to corrupted data.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (23+ messages)  latest in thread

Message-ID: <2049.1493216926@sss.pgh.pa.us>
Permalink:  ../2049.1493216926@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2049.1493216926@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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, nikhils@2ndquadrant.com, simon@2ndquadrant.com, andres@anarazel.de
  Subject: Re: StandbyRecoverPreparedTransactions recovers subtrans links incorrectly
  In-Reply-To: <2049.1493216926@sss.pgh.pa.us>
  References: <20110.1492905318@sss.pgh.pa.us> <20170423001931.wk4os4x6dwtdfwgd@alap3.anarazel.de> <CANP8+jLy1VdopsdCi3c0=msJCfu-oHAhgPJgtKJ84fFN_8EmOw@mail.gmail.com> <20170423232504.o454vbowwvivkuyn@alap3.anarazel.de> <CANP8+j+vcrgv6-KaY_1bdgF7nE2G0r12c398g=7QyazVXem3xg@mail.gmail.com> <20170424185944.bjpb3yizeybv75hd@alap3.anarazel.de> <CANP8+jLcfoCsJb8R57=haWVJewiAkGixpY6MaN-TNpNiaLTnYg@mail.gmail.com> <CAMGcDxfLxpb4iTQVeeJ3s=r4ZEtaHS5L4f_gj8CZtJ_69PcBzw@mail.gmail.com> <2049.1493216926@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