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 1rtkIk-00H8cu-0d for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Apr 2024 08:24:26 +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 1rtkIj-002ui2-6J for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Apr 2024 08:24:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rtkIi-002uht-QC for pgsql-hackers@lists.postgresql.org; Mon, 08 Apr 2024 08:24:24 +0000 Received: from wfout8-smtp.messagingengine.com ([64.147.123.151]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rtkIf-001n8V-Ue for pgsql-hackers@lists.postgresql.org; Mon, 08 Apr 2024 08:24:23 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.west.internal (Postfix) with ESMTP id E4F801C00116; Mon, 8 Apr 2024 04:24:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 08 Apr 2024 04:24:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712564658; x= 1712651058; bh=e7bReDare5sMmZuG9wDRK25xnwsaVFKpXCyy/4ez5NY=; b=K 4ztIfBFiv3OhjFpIFIO4XyhT0JwUn0/9JkbrON1uAU+FU4C+H4jcVDgDYrSFtRQu 4OsK1hv9SG2LiFlE2IImE2eoopbpVO4e7Zf9bEmj0d/Sufpc3MHTLzrLgDuGAnvt bNg7jGFmL3qbHrsXlzwge8I5y/3Z1JDwo12OnYYZ3+WBiSW5w4816SaEfgC+K1HQ aF8YpxgNbjTUxOLYdx+CzI64P+N/HHz63zRIephG3hBthj/oLopCFi4jOJdAD8mC ja4ZCYWxugT5SrzmJr9D3Y0kXmV73+SmHOSkA5ETb2ibn9/H83AZ9SqEAEcQY1E7 bMOEwZPF4FMaqfbQqjHoQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudegiedgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepueeigfffueektdfgteeuuefgtedvueehgfehleefheel jeelfeffjedttdekvdejnecuffhomhgrihhnpehpohhsthhgrhdrvghspdgvnhhtvghrph hrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 8 Apr 2024 04:24:17 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1712564655; bh=351ChRNF3hsohj6qOM0K+35x8Ae8YmgSh9rvFTZhSKc=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=EygByCbEYmFQ2zGUZV5tqVMGU0ISVAACSaVwSK2j5kkmQaJ7sADBtvqm7RGDwiGFR HK/x0TLI0YanO+tced3hIOK8B0phozKsAmyElsQiqpfLJiHxGoEJ/53o5MVyrQ/RJc JI3C0b9XC61X4OiIL4/wNrvpyxZ6Ovmok6oWf4Vqskyj9oFkdIhM8RGpOzbVl9ty5K I4MvyUVZvrN2df2wuFRgM0/VpHdag3ebVNcaKth4E4jGwhcdPv4QgnWovoVXLpKc1M O+KEJXoaoISXUjHwNWpSCyb1SC6SeHxNIJdX4mysQFdvsQkU2QX6lFEGFjS6msPGN4 3mXikURO4mVQA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id CC67D46F; Mon, 8 Apr 2024 10:24:15 +0200 (CEST) Date: Mon, 8 Apr 2024 10:24:15 +0200 From: Alvaro Herrera To: Jeff Davis Cc: Bharath Rupireddy , Tom Lane , Andres Freund , pgsql-hackers@lists.postgresql.org, Jaime Casanova Subject: Re: LogwrtResult contended spinlock Message-ID: <202404080824.zwfgjynpnvif@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <51111525fb84ecdadaf99c13a2fa63e4be08041e.camel@j-davis.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Apr-07, Jeff Davis wrote: > On Sun, 2024-04-07 at 14:19 +0200, Alvaro Herrera wrote: > > I pushed the "copy" pointer now, except that I renamed it to > > "insert", > > which is what we call the operation being tracked.  I also added some > > comments. > > The "copy" pointer, as I called it, is not the same as the "insert" > pointer (as returned by GetXLogInsertRecPtr()). > > LSNs before the "insert" pointer are reserved for WAL inserters (and > may or may not have made it to WAL buffers yet). LSNs before the "copy" > pointer are written to WAL buffers with CopyXLogRecordToWAL() (and may > or may not have been evicted to the OS file yet). It seems a matter of interpretation. WAL insertion starts with reserving the space (in ReserveXLogInsertLocation) and moving the CurrBytePos point forward; the same WAL insertion completes when the actual data has been copied to the buffers. It is this process as a whole that we can an insertion. CurrBytePos (what GetXLogInsertRecPtr returns) is the point where the next insertions are going to occur; the new logInsertResult is the point where previous insertions are known to have completed. We could think about insertions as something that's happening to a range of bytes. CurrBytePos is the high end of that range, logInsertResult is its low end. (Although in reality we don't know the true low end, because the process writing the oldest WAL doesn't advertise as soon as it finishes its insertion, because it doesn't know that it is writing the oldest. We only know that X is this "oldest known" after we have waited for all those that were inserting earlier than X to have finished.) My trouble with the "copy" term is that we don't use that term anywhere in relation to WAL. It's a term we don't need. This "copy" is in reality just the insertion, after it's finished. The "Result" suffix is intended to convey that it's the point where the operation has successfully finished. Maybe we can add some commentary to make this clearer. Now, if you're set on renaming the variable back to Copy, I won't object. Lastly, I just noticed that I forgot credits and discussion link in that commit message. I would have attributed authorship to Bharath though, because I had not realized that this patch had actually been written by you initially[1]. My apologies. [1] https://postgr.es/m/727449f3151c6b9ab76ba706fa4d30bf7b03ad4f.camel@j-davis.com -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/