Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nZK9F-0005em-Nq for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Mar 2022 22:17:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nZK9E-0006H0-J8 for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Mar 2022 22:17:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nZK9E-0006Go-7w for pgsql-hackers@lists.postgresql.org; Tue, 29 Mar 2022 22:17:08 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nZK9B-00016o-N1 for pgsql-hackers@postgresql.org; Tue, 29 Mar 2022 22:17:07 +0000 Received: by mail-io1-xd34.google.com with SMTP id b16so22785511ioz.3 for ; Tue, 29 Mar 2022 15:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=poxx9jihHPcrc2H7iY1V88rvCmJcUCNVeTdNB2tA10U=; b=W0QS1HPaC3akQC1CGa+9e9OIEbhE/YQh5m/mZLLtbgJMYdZH1w9mKmotoMMlO3GUj6 /C9eGgTQYjuUYvonwAblLFKipBDEIeniFXV0Y3vXEzy5/09WwNykAVjxXVYc4AGIPDyG CtlJ8BDSsngWSJ9LZk6VJX6AqX77zXY2QOKneJka1tki3dwKAjZoC3/itbnYiI2DC2DS UjCRGsFg85NIxwCRjFPLW7nVgv7OU8UkQ0BF/Z8pPEhXbgfp3mHhq3zAa3IRiT0ZzTdz YWVjW3MdcRhbWT3+F8255QrzcowjCS8oBNO1Wn7MbGzEqF0kVEKWpWA5OkcslljZGk4Y oVzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=poxx9jihHPcrc2H7iY1V88rvCmJcUCNVeTdNB2tA10U=; b=mtE5I9I0iNiqrGORnwEXgg+8uU0mZjnniWXHyNFZCi14haN2qJt6m8WVYp84yUOHhT LHpFZoJ31VzFsYQYI9AOpRaCO8+UHoNtd+Y5lIwCf+Brs3zVaegchUrobrgNVGpkLIWC qorYn0Fi2LZKM1KJJum5Za/X7zUt9quxbhamTyA+TzU1LbYIhnemzHLaxC0C6kjrBlWy t+rx9yOVurRgWOEvJn0VVMO32IysCJNUO0OzbejUkTUIvT1f907hXNQfV7ytP4yILxXE 6aorKqModVyPlpCpcONcxM47t/PJ7hWCY7RsOAo2UpUtyN5rDkxTTIhg2naQdbupYo8C bcYA== X-Gm-Message-State: AOAM531VKLlKBi6aRDiQLrDWBGDCbeuzP9IVeMdmHf+PNmhhXi1m3hiP jgLLTtWiTJ+mnBYKJEG+tQRa/qN/bdo= X-Google-Smtp-Source: ABdhPJwJ3Ac6q33a0NUADPy5UgsVSO7s6/lKMu4y9VoSLLyn9/PKklZMuSM6TzeFr2CtbiyPypVqKw== X-Received: by 2002:a05:6638:31c1:b0:319:a36f:4120 with SMTP id n1-20020a05663831c100b00319a36f4120mr17770758jav.81.1648592224733; Tue, 29 Mar 2022 15:17:04 -0700 (PDT) Received: from nathanxps13 ([2600:1700:48f8:340f:152d:60b9:a2fc:9231]) by smtp.gmail.com with ESMTPSA id s10-20020a6b740a000000b006413d13477dsm10226709iog.33.2022.03.29.15.17.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 15:17:04 -0700 (PDT) Date: Tue, 29 Mar 2022 15:17:02 -0700 From: Nathan Bossart To: pgsql-hackers@postgresql.org Subject: remove reset_shared() Message-ID: <20220329221702.GA559657@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MGYHOYXEY6WxJCY8" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --MGYHOYXEY6WxJCY8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi hackers, Is there any reason to keep reset_shared() around anymore? It is now just a wrapper function for CreateSharedMemoryAndSemaphores(), and AFAICT the information in the comments is already covered by comments in the shared memory code. I think it's arguable that the name of the function makes it clear that it might recreate the shared memory, but if that is a concern, perhaps we could rename the function to something like CreateOrRecreateSharedMemoryAndSemaphores(). I've attached a patch that simply removes this wrapper function. This is admittedly just nitpicking, so I don't intend to carry this patch further if anyone is opposed. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --MGYHOYXEY6WxJCY8 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-Remove-reset_shared.patch" From 295e1e93a2ff4e655e85040d931c0d332d14b5bd Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Tue, 29 Mar 2022 14:56:47 -0700 Subject: [PATCH v1 1/1] Remove reset_shared(). This is now just a wrapper for CreateSharedMemoryAndSemaphores(), and the information in the comments is already covered by comments in the shared memory code. --- src/backend/postmaster/postmaster.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 80bb269599..f62d12e74a 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -399,7 +399,6 @@ static void getInstallationPaths(const char *argv0); static void checkControlFile(void); static Port *ConnCreate(int serverFd); static void ConnFree(Port *port); -static void reset_shared(void); static void SIGHUP_handler(SIGNAL_ARGS); static void pmdie(SIGNAL_ARGS); static void reaper(SIGNAL_ARGS); @@ -1072,7 +1071,7 @@ PostmasterMain(int argc, char *argv[]) /* * Set up shared memory and semaphores. */ - reset_shared(); + CreateSharedMemoryAndSemaphores(); /* * Estimate number of openable files. This must happen after setting up @@ -2736,23 +2735,6 @@ InitProcessGlobals(void) } -/* - * reset_shared -- reset shared memory and semaphores - */ -static void -reset_shared(void) -{ - /* - * Create or re-create shared memory and semaphores. - * - * Note: in each "cycle of life" we will normally assign the same IPC keys - * (if using SysV shmem and/or semas). This helps ensure that we will - * clean up dead IPC objects if the postmaster crashes and is restarted. - */ - CreateSharedMemoryAndSemaphores(); -} - - /* * SIGHUP -- reread config files, and tell children to do same */ @@ -4109,7 +4091,7 @@ PostmasterStateMachine(void) /* re-read control file into local memory */ LocalProcessControlFile(true); - reset_shared(); + CreateSharedMemoryAndSemaphores(); StartupPID = StartupDataBase(); Assert(StartupPID != 0); -- 2.25.1 --MGYHOYXEY6WxJCY8--