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 1uboVY-005bTR-47 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Jul 2025 22:52:20 +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 1uboVU-005yPQ-SJ for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Jul 2025 22:52:17 +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 1uboVU-005yPB-A9 for pgsql-hackers@lists.postgresql.org; Tue, 15 Jul 2025 22:52:17 +0000 Received: from bramsgout03.huawei.com ([119.8.89.137]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uboVO-007Th7-2d for pgsql-hackers@postgresql.org; Tue, 15 Jul 2025 22:52:12 +0000 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=KPTtmdAQ6fNk5eASeyY9dI2UijVizieuNkOnjPY1qOU=; b=08Kis5O5edf9UkXsjs6ZGpXLquk7/nb1z/kvVnRzFL2AaV5OUvzEFnYWyi5Mu8zInuY818lDy vmTAce6AoW2za0+d4GFNv1fchlu1tiWVnmmoNUvbJURbFlzQ0OsnR+ra0L5wSGxlqVJ2pYeZs82 XxXjnjnWaTg2Deew+blPi/Q= Received: from mail.maildlp.com (unknown [172.18.210.75]) by bramsgout03.huawei.com (SkyGuard) with ESMTPS id 4bhZCq44P7z1mt6Z; Wed, 16 Jul 2025 06:50:47 +0800 (CST) Received: from ytopeml100001.china.huawei.com (unknown [7.184.17.227]) by mail.maildlp.com (Postfix) with ESMTPS id 152B9160045; Wed, 16 Jul 2025 06:52:04 +0800 (CST) Received: from ytopeml500001.china.huawei.com (7.184.16.223) by ytopeml100001.china.huawei.com (7.184.17.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 15 Jul 2025 18:52:01 -0400 Received: from ytopeml500001.china.huawei.com ([7.184.16.223]) by ytopeml500001.china.huawei.com ([7.184.16.223]) with mapi id 15.01.2507.039; Tue, 15 Jul 2025 18:52:01 -0400 From: Jack Ng To: Dmitry Dolgov <9erthalion6@gmail.com> CC: Andres Freund , Thom Brown , "Ashutosh Bapat" , Tomas Vondra , "Thomas Munro" , PostgreSQL-development , Ni Ku Subject: RE: Changing shared_buffers without restart Thread-Topic: Changing shared_buffers without restart Thread-Index: AQHb4czjArbykOnCnUaEQCqOWcY4q7QfGxSAgAJTTACAAPSigIADCKUAgAAFeACAC1ixAIAArMiAgAA2XgCAAARBgIAACBkAgAAIcACAAAIegIAAOSQAgAADOQCAAAGrAIAAAZKAgAAGWACAAAVUAIAABgaAgAAEhICAAAj0AP//vbtQgABY5oCAAbaCAA== Date: Tue, 15 Jul 2025 22:52:01 +0000 Message-ID: References: <1ABF6EF8-8556-4C1D-BA34-142DC4813CED@anarazel.de> <6r37jr5f5cfwve3tycgvmasxdfih3xv7jfua24ewt7ebnh4sn2@vzxf5ngdkgmb> In-Reply-To: <6r37jr5f5cfwve3tycgvmasxdfih3xv7jfua24ewt7ebnh4sn2@vzxf5ngdkgmb> Accept-Language: en-CA, zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.218.176.22] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk >> On Mon, Jul 14, 2025 at 03:18:10PM +0000, Jack Ng wrote: >> Just brain-storming here... would moving NBuffers to shared memory solve >this specific issue? Though I'm pretty sure that would open up a new set o= f >synchronization issues elsewhere, so I'm not sure if there's a net gain. > >It's in fact already happening, there is a shared structure that described= the >resize status. But if I get everything right, it doesn't solve all the pro= blems. Hi Dmitry,=20 Just to clarify, you're not only referring to the ShmemControl::NSharedBuff= ers and related logic in the current patches, but actually getting rid of per-p= rocess NBuffers completely and use ShmemControl::NSharedBuffers everywhere instead= (or something along those lines)? So that when the coordinator updates ShmemControl::NSharedBuffers, everyone sees the new value right away. I guess this is part of the "simplified design" you mentioned several posts= earlier? I also thought about that approach more, and there seems to be new synchron= ization issues we would need to deal with, like: 1. Mid-execution change of NBuffers in functions like BufferSync and BgBuff= erSync, which could cause correctness and performance issues. I suppose most of the= m are solvable with atomics and shared r/w locks etc, but at the cost of high= er performance overheads. 2. NBuffers becomes inconsistent with the underlying shared memory mappings= for a period of time for each process. Currently both are updated in AnonymousShm= emResize and AdjustShmemSize "atomically" for a process, so I wonder if letting them= get out-of-sync (even for a brief period) could be problematic. I agree it doesn't seem to solve all the problems. It can simplify certain = aspects of the design, but may also introduce new issues. Overall not a "silver bul= let" :) Jack