Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VCUuW-00063b-6H for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Aug 2013 13:26:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VCUuV-0004IC-Mn for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Aug 2013 13:26:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VCUuV-0004I6-1z for pgsql-bugs@postgresql.org; Thu, 22 Aug 2013 13:26:47 +0000 Received: from moutng.kundenserver.de ([212.227.126.187]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VCUuR-0008Fp-Ty for pgsql-bugs@postgresql.org; Thu, 22 Aug 2013 13:26:46 +0000 Received: from anarazel.de (p5DDC651B.dip0.t-ipconnect.de [93.220.101.27]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0M8hNb-1VyoEy443f-00wF8m; Thu, 22 Aug 2013 15:26:36 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 99BB81019A2; Thu, 22 Aug 2013 15:30:35 +0200 (CEST) Date: Thu, 22 Aug 2013 15:30:35 +0200 From: Andres Freund To: =?utf-8?B?44OA44Oz44Of44Oz44OV44O844Oz?= Cc: pgsql-bugs@postgresql.org, 'Akio Iwaasa' Subject: Re: After promote, DB can not UPDATE with SAVEPOINT (could not access status of transaction 1409172) Message-ID: <20130822133035.GA17006@awork2.anarazel.de> References: <008301ce9f39$fa67c520$ef374f60$@mxm.nes.nec.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <008301ce9f39$fa67c520$ef374f60$@mxm.nes.nec.co.jp> Content-Transfer-Encoding: quoted-printable X-Provags-ID: V02:K0:Maj/3UOdhGMSuW6b7Xz/OqUCugbAJ85j4MeqvODE2xV Zs1OeJJRsIxnYyyGe6kU6UhN84AnSy6kT0OtEKP10EgnKuVe9Z EIGgRryXR2bEts4WRzwz9fkyGMWKHcofWuK0WblaBL2t7KK9+w AXm4LUuuGLReQWpH3IdTnFDCXjbfcIGbvu2wJNfXqj649C9Dxv Xn/PTZqDgl67cScAXfBneis8xIa+ndEeT5pgt15KHhuNJUj4VN uK1dIU2zmYSrWL1Shm98aeUyOrDCsKy4uGvn7t+KHWS4fwrFcZ 7fV+aY3UvWD3qQ6gVG6P31cS7Pb075i7anoev2Ya2xsFw9Ud+c K07UgeDYFgKvgy78/L1e15YXHg0SRkbT4tL467FNe X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hi, On 2013-08-22 22:17:40 +0900, =E3=83=80=E3=83=B3=E3=83=9F=E3=83=B3=E3=83=95= =E3=83=BC=E3=83=B3 wrote: > I've get found out that issue in my project. > Update in PRIMARY while pg_basebackup is performing,=20 > Can cause the STANDBY could not UPDATE after promote. >=20 > In Standby Node, when first XID of a page come, pg_subtrans=20 > must be extended by ExtendSUBTRANS function. >=20 > But if that XID created while pg_basebackup (with "-x" option)=20 > was performing, it did not extend. >=20 > Due to that, after basebackup complete, start that DB and do=20 > promote complete. It failed in SAVEPOINT UPDATE query like follows. >=20 > --- > postgres=3D# BEGIN; > postgres=3D# SAVEPOINT testsavepoint; > postgres=3D# UPDATE test_tbl SET name =3D 'test'; > ERROR: could not access status of transaction 1409172 > DETAIL: Could not read from file "pg_subtrans/0015" at offset 131072: Su= ccess. > --- >=20 > I've also confirm source and realize that, >=20 > When StartupXLOG call RecordKnownAssignedTransactionIds > (in the "main redo apply loop"), the "standbyState" still=20 > was STANDBY_INITIALIZED, so it is returned without goto=20 > ExtendSUBTRANS (to check and extend space for pg_subtrans). >=20 > Therefor, after STANDBY promote, when UPDATE query made by=20 > SAVEPOINT is executed, the process as follow is performed=20 > and get the above ERROR in SimpleLruReadPage function. >=20 > AssignTransactionId =3D> SubTransSetParent =3D> SubTransSetParent =3D> Si= mpleLruReadPage=20 >=20 > I think that ExtendSUBTRANS must be called even if "standbyState"=20 > in STANDBY_INITIALIZED in order to avoid the case above. >=20 > I also attach a patch. Could anyone confirm for me. Nice diagnosis and thanks for the patch! I think the the issue has already been fixed while investigating a similar issue, could you verify that the current git version works for you? c.f. commit 99ee15b315c187045a95db7b27fd9d866aea93e0 Greetings, Andres Freund --=20 Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs