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 1iSZjA-0007Iu-31 for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Nov 2019 04:49:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iSZj7-0005sD-Sj for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Nov 2019 04:48:57 +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 1iSZj5-0005s6-TO for pgsql-hackers@lists.postgresql.org; Thu, 07 Nov 2019 04:48:57 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iSZiz-0004G1-SC for pgsql-hackers@postgresql.org; Thu, 07 Nov 2019 04:48:53 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 3166221249; Wed, 6 Nov 2019 23:48:47 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 06 Nov 2019 23:48:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=6ms4SHEI9v8Zho22ywtXGNnyGW8 LN4PE3x+GfMe8i8o=; b=NL0/UAbvj3OIPlqbIM6AKUkhAAB61phRDsRYkgYBvM8 h33S3LAqBVntibN0xVR3D/H9RRV1GO5NKEdtlJUMsTKAZaLXr9jSvlxeBZMvkN4J n8c9x5acuAcRz2W9f+GgpnfF7OUC4S0ATZM+h4q2k1WwawKCtSqvsqgnSKM/s1r0 5ONF1Ye1hIbb9xKlAPebtCxD9sJHlbvvfv98/fHl0LBm16eU7N/2IiYJ0holFqlR MRnOTHAb2ZbfqRUIbgALGWDygF42G6Xbo9j3CezSKrzngTpzfyMLfKYJW5sijhbo TC8PWX6G1bdjsf+WP/YmR+8gMOeJFF/i/n7AhwRDllA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=6ms4SH EI9v8Zho22ywtXGNnyGW8LN4PE3x+GfMe8i8o=; b=mtMmGtn3jgZ+6R8mIu+j5Y ff+iRhXv7FRQBsxJyDz1vjrKey32bDWNeu/0jeZezHyV27rfKT8c9IHVL31n8Y71 p05gjgR5YddD2u5RdnODEiY4fgcaqk3pDRTtJnvL/FZbC2MJk3uA0V3P/2ttTVHo z336G7UJWs0T10oFUj9Hw3FaQZOL1kdQ7MazJZUOGLxAtPgBfHXPboUtCEdjBfGW rNBaTtTW+gt5I3YiNEs/27NTq92fmnjuKTGWi5sqPNNsTN8wvEm3EXdjiFusTLbA Hk6pzdsGNHUMiFlodlLV+/6fmbA1i28jrFH1qwQLD9XdBUUx9Q74vKSRdE+61rGw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedruddukedgjeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucfkphepudduuddruddtvddrudektddrudekheenucfrrghr rghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiienucevlh hushhtvghrufhiiigvpedt X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id D295680064; Wed, 6 Nov 2019 23:48:44 -0500 (EST) Date: Thu, 7 Nov 2019 13:48:41 +0900 From: Michael Paquier To: Antonin Houska Cc: Alvaro Herrera , Thomas Munro , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: Attempt to consolidate reading of XLOG page Message-ID: <20191107044841.GL1768@paquier.xyz> References: <20190927191736.GA13447@alvherre.pgsql> <75489.1570183871@antos> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="YIwHDYD8sUXtBKvt" Content-Disposition: inline In-Reply-To: <75489.1570183871@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --YIwHDYD8sUXtBKvt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Oct 04, 2019 at 12:11:11PM +0200, Antonin Houska wrote: > This is the next version. So... These are the two last bits to look at, reducing a bit the code size: 5 files changed, 396 insertions(+), 419 deletions(-) And what this patch set does is to refactor the routines we use now in xlogreader.c to read a page by having new callbacks to open a segment, as that's basically the only difference between the context of a WAL sender, pg_waldump and recovery. Here are some comments reading through the code. + * Note that XLogRead(), if used, should have updated the "seg" too for + * its own reasons, however we cannot rely on ->read_page() to call + * XLogRead(). Why? Your patch removes all the three optional lseek() calls which can happen in a segment. Am I missing something but isn't that plain wrong? You could reuse the error context for that as well if an error happens as what's needed is basically the segment name and the LSN offset. All the callers of XLogReadProcessError() are in src/backend/, so it seems to me that there is no point to keep that in xlogreader.c but it should be instead in xlogutils.c, no? It seems to me that this is more like XLogGenerateError, or just XLogError(). We have been using xlog as an acronym in many places of the code, so switching now to wal just for the past matter of the pg_xlog -> pg_wal switch does not seem worth bothering. +read_local_xlog_page_segment_open(XLogSegNo nextSegNo, + WALSegmentContext *segcxt, Could you think about a more simple name here? It is a callback to open a new segment, so it seems to me that we could call it just open_segment_callback(). There is also no point in using a pointer to the TLI, no? + * Read 'count' bytes from WAL fetched from timeline 'tli' into 'buf', + * starting at location 'startptr'. 'seg' is the last segment used, + * 'openSegment' is a callback to opens the next segment if needed and + * 'segcxt' is additional segment info that does not fit into 'seg'. A typo and the last part of the last sentence could be better worded. -- Michael --YIwHDYD8sUXtBKvt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl3DoikACgkQnvQgOdby QH2CMQ//TUo9nBOUt14QZR7r9bE+3fSiSd+d59cXQFHcSQhpiPjl55lctz+/1J0m ghZvjxtaiexE1aAWqNS74Htb9H+35WAy1B81vaPPbLc3qCnfAdHAS7elO+qJHFVl egbcQfV9CdJ77AnPe1AsocOzIrGJ0PdXmcxFnA9mR4pa6dxvLNsAM8JW/HKHDSnG Qh8JEoeZhlaPzQBr/V6zEX3BFrQs2UKqvipsXQRmr1uZ+lDaYl+FS9k3ykJNNXXX rV3XUI2loFkA/rCGa1tNEz2zvVq2KdomyUdTHYeDDcuxd9IszMKQNf2C9pGOnbSd AxfznRjE4pDngbWTmmvR1AGm0FVkKwLl4Ig3XBHMOhqTF0hSmzrA3VL5++qJXyfd kDCj5xjDgX1K5JxzKH6t7+q8Vt0VRTVN9W6dIcwGQA+LuAGcHt3lBqugZZ20POlt yS9euCluX3mQqrwohOj3iali/IC3eeG7aKWzs1dnMD/DoU8NgFYlLYDBP/j00LRY 6W8QUFaj3LZfo4b68ncmy7Eow5lsZGUItCZRbXvdBTfMulJlmaUhLkg6Bql1C18K zry752fQOV2yPvq16VONk4ae948R8Q+DyS6DoKfTyVFG5lxTOfXVkz9tJMhOxJ8Y GPUxujNU13W6U6qrAf8VzgxTaQnv8sU8vIiIoLhOJBxZbOcSRuc= =hj/9 -----END PGP SIGNATURE----- --YIwHDYD8sUXtBKvt--