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 1v8uMU-0070Sm-Fm for pgsql-general@arkaria.postgresql.org; Wed, 15 Oct 2025 05:47:46 +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 1v8uMT-004jw0-D8 for pgsql-general@arkaria.postgresql.org; Wed, 15 Oct 2025 05:47:44 +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 1v8uMT-004jvr-0f for pgsql-general@lists.postgresql.org; Wed, 15 Oct 2025 05:47:44 +0000 Received: from sm-r-003-dus.org-dns.com ([89.107.70.12]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v8uMP-002GQ5-2F for pgsql-general@lists.postgresql.org; Wed, 15 Oct 2025 05:47:43 +0000 Received: from smarthost-dus.org-dns.com (localhost [127.0.0.1]) by smarthost-dus.org-dns.com (Postfix) with ESMTP id D2F17A11E6 for ; Wed, 15 Oct 2025 07:47:39 +0200 (CEST) Received: by smarthost-dus.org-dns.com (Postfix, from userid 1001) id C40C8A11DD; Wed, 15 Oct 2025 07:47:39 +0200 (CEST) X-Spam-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,DMARC_PASS,KAM_INFOUSMEBIZ, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 Received: from ha01s018.org-dns.com (ha01s018.org-dns.com [62.108.32.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smarthost-dus.org-dns.com (Postfix) with ESMTPS id 6819DA11E6 for ; Wed, 15 Oct 2025 07:47:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gelassene-pferde.biz; s=default; t=1760507256; bh=Hy6otZHrBTD4AhQr1cNzvm4uYS6qKmzwx56QedXjm2k=; h=From:To:Subject; b=y6TjjrkjpiU0gwrPLmu3Bg0dzGhUVvAYPflkC6lMAbxDf9a0H/rOYYWh4LtFkTmmO TUzqWApIdo2XJemRrAS/kQcJsoSuyFcXjsSbE3j58M8Gn014vc8GVJVzDvgfg5dzwI Ubv3aNTVIU4TpktYlTaD4JE1W4V7FO3+LGSBYVic= Authentication-Results: ha01s018.org-dns.com; spf=pass (sender IP is 178.197.239.130) smtp.mailfrom=thiemo@gelassene-pferde.biz smtp.helo=dummy.faircode.eu Received-SPF: pass (ha01s018.org-dns.com: connection is authenticated) Date: Wed, 15 Oct 2025 07:47:34 +0200 (GMT+02:00) From: Thiemo Kellner To: pgsql-general@lists.postgresql.org Message-ID: <235dd027-1685-4ce6-9b77-293ae6bba16b@gelassene-pferde.biz> In-Reply-To: References: <73ff46d2-0bad-4a8d-9928-e494c2d5b0d1@gmail.com> <93702.1760321769@sss.pgh.pa.us> <233155.1760369829@sss.pgh.pa.us> Subject: Re: Option on `postgres` CLI to shutdown when there are no more active connections? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Correlation-ID: <235dd027-1685-4ce6-9b77-293ae6bba16b@gelassene-pferde.biz> X-PPP-Message-ID: <176050725606.2813499.5699923514261929856@ha01s018.org-dns.com> X-PPP-Vhost: gelassene-pferde.biz X-POWERED-BY: wint.global - AV:CLEAN SPAM:OK List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 14.10.2025 23:49:21 David Barsky : > 1. If that script is cancelled or interrupted for any reason, it=E2=80=99= s possible that > =C2=A0 =C2=A0`pg_ctl stop` won't be called and I'd have a leaked process. As others stated, some shells have the trapping functionality. > I could mitigate > =C2=A0 =C2=A0this by calling `pg_ctl stop` at the *start* of the script, = but that adds a > =C2=A0 =C2=A0bit of latency I'd prefer to avoid. I wonder what the reason is to avoid that latency in the script. Spinning d= own the DB will take time anyway. Would it be possible to make a procedure run at the start of the DB, like a= daemon, checking for the last connection to quit if there has been one, an= d to shutdown the DB in an ordered manner? Just my two Rappen