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 1rD2oq-000j7M-2z for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Dec 2023 13:29: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 1rD2oo-004ekf-O1 for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Dec 2023 13:29:02 +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 1rD2on-004ejz-7J for pgsql-hackers@lists.postgresql.org; Tue, 12 Dec 2023 13:29:02 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rD2ok-00A2KV-0d for pgsql-hackers@lists.postgresql.org; Tue, 12 Dec 2023 13:28:59 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id BDAB35C0306; Tue, 12 Dec 2023 08:28:55 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 12 Dec 2023 08:28:55 -0500 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=fm1; t=1702387735; x= 1702474135; bh=hCqJAEyz2EDS8i22g/KMAdYGruwmT4jiDBjnQIoFfhw=; b=o TW4DiHZntQwsxNXVGZodSSjjauBo50rn+2Cl+1lIVYelJ45lhNXsYa62tWBq0CiN q6V6nsijboEAPHSMyIjmZnFEmtbnJRMg7oLpmlJTCfDDxE4kdzixWfFZg36rjaXF CIau8nwlwHJLCHhiEYECU4JU6oy1PIPCTWPNPAdXBMUWMdc1s/otXhfYzCkazsCV BhYJsECQAL7/CcXlpQrep3+anbPlhgJmp2LyVHIVXG3dgPTTG0h1T2uqKAlaqfiH ad3eAjh/+RxbTpP+mcK+e8qyaY9YV/HF3MrPVGOk8kNBkq9XK7pFm2Oaz/8dBInY ZPew5IIKTAB1ybeZ5MpMg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudelgedgheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Dec 2023 08:28:55 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1702387731; bh=yrS+ONVy0RvxUQPT7oD/eYR+S3gpYtWxpvRfAZeCib0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=PAQO4D1E2W/Q704faUf4fVxknlE99lV7Lmj7SbJN+VBcrubfHNn0JoZrtKxRudNwH M5bdShKCdw6LmWX9zEGAD4baSLsH8MWKYvkYtS3vA/Mim73iSRbXYRI3MnEId3OAJL QHp8AqS76hjAnzuowW3/cd3MkC2Ic2RZsHcfVvBVuP91Ag9YlJcmCTOogvwLOBfllJ hX/C5aa0Cv1DC4J59HpTXd6B1SXHUuhc3YQ7YutVHHVci7WN4ydZ6UbqhrriY7tR2i EOyWloB+JXSXVR3DWb+3S/eUpjAi0dRDYUoMlCbYrYzbtGhddeAcU4NNp2+VqFv/Nw s2puxRPmg/Yhg== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id CAA693B5; Tue, 12 Dec 2023 14:28:51 +0100 (CET) Date: Tue, 12 Dec 2023 14:28:51 +0100 From: Alvaro Herrera To: Dilip Kumar Cc: tender wang , PostgreSQL Hackers , "Andrey M. Borodin" Subject: Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock Message-ID: <202312121328.hntemjpqg4hd@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk [Added Andrey again in CC, because as I understand they are using this code or something like it in production. Please don't randomly remove people from CC lists.] I've been looking at this some more, and I'm not confident in that the group clog update stuff is correct. I think the injection points test case was good enough to discover a problem, but it's hard to get peace of mind that there aren't other, more subtle problems. The problem I see is that the group update mechanism is designed around contention of the global xact-SLRU control lock; it uses atomics to coordinate a single queue when the lock is contended. So if we split up the global SLRU control lock using banks, then multiple processes using different bank locks might not contend. OK, this is fine, but what happens if two separate groups of processes encounter contention on two different bank locks? I think they will both try to update the same queue, and coordinate access to that *using different bank locks*. I don't see how can this work correctly. I suspect the first part of that algorithm, where atomics are used to create the list without a lock, might work fine. But will each "leader" process, each of which is potentially using a different bank lock, coordinate correctly? Maybe this works correctly because only one process will find the queue head not empty? If this is what happens, then there needs to be comments about it. Without any explanation, this seems broken and potentially dangerous, as some transaction commit bits might become lost given high enough concurrency and bad luck. Maybe this can be made to work by having one more lwlock that we use solely to coordinate this task. Though we would have to demonstrate that coordinating this task with a different lock works correctly in conjunction with the per-bank lwlock usage in the regular slru.c paths. Andrey, do you have any stress tests or anything else that you used to gain confidence in this code? -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "El sabio habla porque tiene algo que decir; el tonto, porque tiene que decir algo" (Platon).