Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3NwC-0008J1-Bq for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Apr 2017 14:29:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d3NwB-0001Hs-SU for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Apr 2017 14:28:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d3NwA-0001HR-LW for pgsql-hackers@postgresql.org; Wed, 26 Apr 2017 14:28:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d3Nw3-00045U-DJ for pgsql-hackers@postgresql.org; Wed, 26 Apr 2017 14:28:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v3QESkGn002050; Wed, 26 Apr 2017 10:28:46 -0400 From: Tom Lane To: Nikhil Sontakke cc: Simon Riggs , Andres Freund , PostgreSQL-development Subject: Re: StandbyRecoverPreparedTransactions recovers subtrans links incorrectly In-reply-to: References: <20110.1492905318@sss.pgh.pa.us> <20170423001931.wk4os4x6dwtdfwgd@alap3.anarazel.de> <20170423232504.o454vbowwvivkuyn@alap3.anarazel.de> <20170424185944.bjpb3yizeybv75hd@alap3.anarazel.de> Comments: In-reply-to Nikhil Sontakke message dated "Wed, 26 Apr 2017 19:30:50 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2048.1493216926.1@sss.pgh.pa.us> Date: Wed, 26 Apr 2017 10:28:46 -0400 Message-ID: <2049.1493216926@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Nikhil Sontakke 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