Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDvv6-00079O-3v for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Sep 2019 19:28:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDvv5-0003CY-0C for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Sep 2019 19:28:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDvv4-0003CA-Nx for pgsql-hackers@lists.postgresql.org; Fri, 27 Sep 2019 19:28:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDvv2-0001JA-Hs for pgsql-hackers@postgresql.org; Fri, 27 Sep 2019 19:28:46 +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 x8RJSc2J020330; Fri, 27 Sep 2019 15:28:38 -0400 From: Tom Lane To: Alvaro Herrera cc: Antonin Houska , Thomas Munro , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: Attempt to consolidate reading of XLOG page In-reply-to: <20190927191736.GA13447@alvherre.pgsql> References: <20190927191736.GA13447@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Fri, 27 Sep 2019 16:17:36 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20328.1569612518.1@sss.pgh.pa.us> Date: Fri, 27 Sep 2019 15:28:38 -0400 Message-ID: <20329.1569612518@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2019-Sep-27, Antonin Houska wrote: >>> You placed the errinfo in XLogRead's stack rather than its callers' ... >>> I don't think that works, because as soon as XLogRead returns that >>> memory is no longer guaranteed to exist. >> I was aware of this problem, therefore I defined the field as static: >> >> +XLogReadError * >> +XLogRead(char *buf, XLogRecPtr startptr, Size count, TimeLineID *tli_p, >> + WALOpenSegment *seg, WALSegmentContext *segcxt, >> + WALSegmentOpen openSegment) >> +{ >> + char *p; >> + XLogRecPtr recptr; >> + Size nbytes; >> + static XLogReadError errinfo; > I see. That seems like an absolutely terrible "fix". We don't really want XLogRead to be defined in a way that forces it to be non-reentrant do we? regards, tom lane