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 1iE7sx-0001KY-4n for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Sep 2019 08:15:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iE7sv-0005EW-2Y for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Sep 2019 08:15:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iE7su-0005Dr-Nw for pgsql-hackers@lists.postgresql.org; Sat, 28 Sep 2019 08:15:20 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iE7sl-0008Ty-IY for pgsql-hackers@postgresql.org; Sat, 28 Sep 2019 08:15:19 +0000 Received: by mail-wm1-x344.google.com with SMTP id y135so10157675wmc.1 for ; Sat, 28 Sep 2019 01:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:comments:mime-version :content-id:date:message-id; bh=qwQpAQPQ6B/4/k3XbvRVlvc5/qPKXXO5LByDx8j9OMc=; b=1iwv1h1XanV0lcbnRkV2EH85z0J13cdgQX66ksedsIUfWlzRJG4nlclbHgJw25ddA9 S+3jS4Wxj2sGRYTb5mNzxCRx6Wo87WxKr+CM2QYfDByhXaJGZksk6cZNmOOb94y8xlsj hExhbBCI+8FaBLK1CfZgPgobBlGiQ+y/pDs3Bl1Tlcl7Woy0XRjeeiNi2m9YGiSUhUj3 ESulpkQca7ymFY9L5nW5ktZJ7ZWu+txMXuXUuioZFuAfu74yXMNH0u5Rvf/giYCv1yY5 fhd49T4vZRIe6oYhHV1txFDCF/jdODTWKGzRkCXe9pbtgJeBzcVaht8KgEyyCwjw4X6Q EaOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :comments:mime-version:content-id:date:message-id; bh=qwQpAQPQ6B/4/k3XbvRVlvc5/qPKXXO5LByDx8j9OMc=; b=nrWdci0/Us3VtNfRqrFzM3pAtv1pkfDZoiMNzj9IXvnc2sn8f2IkGyUbeDz8MxTaUh V2pugQwr1Efae/VMQhh7VWBYQZEVbjv6Zl1Iy8pce40uPPZF00foi7Z6pDHBur+YL84v ZjxKHcbpxGK3+7EORIe4v1vvyyomSzIDYAEsomkxtBNQGjKshX5uFkEPi/V7AcJdMh04 hYUsG1e0rrmCE24X+paqaAfSvV6qr4H3X7aRE8RMNlHij5SeSPcd5xT5Od7TBnneseWX 8Cy0neQbj1cCba76apVDhZ6GmZumxeZkYW9zxMKhxjMrMiXx6XKFgaxSCQpmqVUrfEZy egDw== X-Gm-Message-State: APjAAAUbGIVEiSMcUMRXID7iExAMBCWN1P+TNcwOEXT4UNQssy9Jg5oU 2S9AslF8PjMlrgaI5Q5lmtd+yg== X-Google-Smtp-Source: APXvYqy99/ZiDpkfNFD1SYhqznIxwD4jw/82KroCO2htnBP8sx3rfh2WHCFCaUp86LGqrIYm0888TA== X-Received: by 2002:a1c:3946:: with SMTP id g67mr10701668wma.52.1569658510276; Sat, 28 Sep 2019 01:15:10 -0700 (PDT) Received: from antos ([77.87.240.5]) by smtp.gmail.com with ESMTPSA id e9sm21676020wme.3.2019.09.28.01.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2019 01:15:09 -0700 (PDT) From: Antonin Houska To: Tom Lane cc: Alvaro Herrera , Thomas Munro , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: Attempt to consolidate reading of XLOG page In-reply-to: <20329.1569612518@sss.pgh.pa.us> References: <20190927191736.GA13447@alvherre.pgsql> <20329.1569612518@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 27 Sep 2019 15:28:38 -0400." X-Mailer: MH-E 8.6+git; nmh 1.7; GNU Emacs 26.2.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7763.1569658556.1@antos> Date: Sat, 28 Sep 2019 10:15:56 +0200 Message-ID: <7764.1569658556@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tom Lane wrote: > 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? Good point. I forgot that the XLOG reader can be used by frontends, so thread safety is important here. -- Antonin Houska Web: https://www.cybertec-postgresql.com