Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rS0eg-00AmbW-Jx for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jan 2024 20:12:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rS0ef-006nYC-J8 for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jan 2024 20:12:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rS0ef-006nY3-9Z for pgsql-hackers@lists.postgresql.org; Mon, 22 Jan 2024 20:12:25 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rS0ed-003B2F-2w for pgsql-hackers@lists.postgresql.org; Mon, 22 Jan 2024 20:12:24 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 888C232009F8; Mon, 22 Jan 2024 15:12:20 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 22 Jan 2024 15:12:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1705954340; x=1706040740; bh=raJz1bn7gp e5YLVHHCgAF9qz5xuURCW06W52hiuBlfs=; b=ybcUad/q0WuSRA61wD1UrC9N7m GUbXl9LqO++vhgt6hAqkVmhyM0jroPH/ga/jeoA/jXrlMeGImJPB2uOk66VnPUlH IvozJH/+mT7wCPVAWcwrarroXosqa59BlGmS84r4HIwqq5Sbv+62nLQhfX2NCmYU enllxSI+aqAZWaGH06g9Rjp1lyexB77qt3AFfbs4Gjw0LwrY/tlgDCepuprIYBzW xXozm/t+IRRnjRfm2rKJf8FlUxvzA8qTfedFE8zG8pI9vobqpryZPO5Z8/jSqMEZ v8JoBtacCRKgkPpqFYvggk/yfj/FYhcpwLGi6gNnuy/uUc2G3vV14WiSVp4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1705954340; x=1706040740; bh=raJz1bn7gpe5YLVHHCgAF9qz5xuU RCW06W52hiuBlfs=; b=XHv6iJHuasJq9j/+v94LFhhfYyM79aGeyjEqTYkIsSvY FPh2sT7DwBJeskEMnltj5zTdZuF1VMtdVh11/rJBpfBtD2pbFlsc4P1YUndnijcZ uIfJ54lnozGBUmaB8y8io9Z6G3zqDu7/qiZ4ahPJsOs8iGkP7rwfWLtJPrsmeSHp M7tmRNo2bgRL8diEDv2AW2Zw3GGBur10tuDQnsU9omZQklfARNQwtafQKeHTm2u4 rMdampEy0wDcUXtz9vAul51Y2JyPzti98c6JOQJV7A+mLduKOn7eLpc/XVCMJMBc mlEzu6YbBH7ly8dkwMiBbw5JeX9T4RcuTxRrXcXkLQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdekiedgudefvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgu rhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtf frrghtthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteev udeitedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpegrnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 22 Jan 2024 15:12:19 -0500 (EST) Date: Mon, 22 Jan 2024 12:12:18 -0800 From: Andres Freund To: Bharath Rupireddy Cc: Jeff Davis , Dilip Kumar , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org, Nathan Bossart , Masahiko Sawada Subject: Re: Improve WALRead() to suck data directly from WAL buffers when possible Message-ID: <20240122201218.bclrdkwpmuk26fl3@awork3.anarazel.de> References: <20231104004348.zhxzk2p266i3r2z2@awork3.anarazel.de> <20231109205836.zjoawdrn4q77yemv@awork3.anarazel.de> <3750ff9c2a5556808827e7fc5bcc0bd16e9facf4.camel@j-davis.com> <73df9831747b01ced949102610dc44ca6026ee1c.camel@j-davis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2024-01-10 19:59:29 +0530, Bharath Rupireddy wrote: > + /* > + * Typically, we must not read a WAL buffer page that just got > + * initialized. Because we waited enough for the in-progress WAL > + * insertions to finish above. However, there can exist a slight > + * window after the above wait finishes in which the read buffer page > + * can get replaced especially under high WAL generation rates. After > + * all, we are reading from WAL buffers without any locks here. So, > + * let's not count such a page in. > + */ > + phdr = (XLogPageHeader) page; > + if (!(phdr->xlp_magic == XLOG_PAGE_MAGIC && > + phdr->xlp_pageaddr == (ptr - (ptr % XLOG_BLCKSZ)) && > + phdr->xlp_tli == tli)) > + break; I still think that anything that requires such checks shouldn't be merged. It's completely bogus to check page contents for validity when we should have metadata telling us which range of the buffers is valid and which not. Greetings, Andres Freund