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 1rZclc-005Xcs-4o for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Feb 2024 20:19:04 +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 1rZclb-00Cnhh-Ad for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Feb 2024 20:19:03 +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 1rZcla-00CnhZ-AW for pgsql-hackers@lists.postgresql.org; Mon, 12 Feb 2024 20:19:03 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rZclX-006rgg-Do for pgsql-hackers@lists.postgresql.org; Mon, 12 Feb 2024 20:19:01 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id E07A13200495; Mon, 12 Feb 2024 15:18:54 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 12 Feb 2024 15:18:55 -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=1707769134; x=1707855534; bh=mTR+vEogRa 8QjquHUJp+85Jebo/PgvtnjbTddkVKIAc=; b=Kd2TeOQMsjnRdJIsqBLxbqGUL6 i1eBIDOP/pDthn+k6EJUWq7qwnlwhJG79ObC3gF30JATQojPYiZeK9sm1OJqlvlb uWqTnQydo2E9pUw6aZvsW1dzwlh/lSvWMfQCECPVhvSQtDpqSqTWsrf3hw4rcAUm Cok4cx4PuyKF7tIlww8UverYeKgzbZ5tMEw/Y/LQ2HrHpQQVw46cqdb5q0M8W1RO rd0YVJIk93SMHzf415JsmDv7zwlGc+kvbRuAXKWbRhsVRx/zL9DVF9BLd/XsQ7QM T944vglcA+8sjUHLwUI3di+3tANWnXVEOsDyV2TxNk4KIcFh+DwbBWQxF4FQ== 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=1707769134; x=1707855534; bh=mTR+vEogRa8QjquHUJp+85Jebo/P gvtnjbTddkVKIAc=; b=PA6gSHPgXWxVLp0BGZdllWPZkYvuaumi2HGYolhrNf1+ fqIdHz5UayJOJgkAQZ10D0eVJrhZ2pytFB0ZeMkwTDs/g2iiyoWFFFHualOyCyLz wS8foczAjVVL7c77qnift60mzc0+DSnQJ4LneKaSmkyZi9dMJBJh/1f5uPodjUwX GW/opLwPDkAMpNm4co5fXWqGTUUsaDpPnCm2yhnRpF919Z87vvy+fuaHRDqVuEWR VxAOVYH4buWKuCRLWJODXmmjmB5Ww6UfkL1eyJZ5ZmRo0wxOArejYrdN5TaD7o3u IkC9nVPUD9sS+ysV5o3dauF5DW6R0r6962wVZ+QfnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefgddufeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetvedu ieettddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Feb 2024 15:18:53 -0500 (EST) Date: Mon, 12 Feb 2024 12:18:53 -0800 From: Andres Freund To: Jeff Davis Cc: Bharath Rupireddy , Alvaro Herrera , 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: <20240212201853.r6dl25onohrwagxt@awork3.anarazel.de> References: <202401301731.o3cthlcry4ve@alvherre.pgsql> 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-02-12 11:33:24 -0800, Jeff Davis wrote: > On Wed, 2024-01-31 at 14:30 +0530, Bharath Rupireddy wrote: > > Please see the attached v22 patch set. > > Committed 0001. Yay, I think this is very cool. There are plenty other improvements than can be based on this... One thing I'm a bit confused in the code is the following: + /* + * Don't read past the available WAL data. + * + * Check using local copy of LogwrtResult. Ordinarily it's been updated by + * the caller when determining how far to read; but if not, it just means + * we'll read less data. + * + * XXX: the available WAL could be extended to the WAL insert pointer by + * calling WaitXLogInsertionsToFinish(). + */ + upto = Min(startptr + count, LogwrtResult.Write); + nbytes = upto - startptr; Shouldn't it pretty much be a bug to ever encounter this? There aren't equivalent checks in WALRead(), so any user of WALReadFromBuffers() that then falls back to WALRead() is just going to send unwritten data. ISTM that this should be an assertion or error. Greetings, Andres Freund