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 1v8mlJ-003IJr-6O for pgsql-general@arkaria.postgresql.org; Tue, 14 Oct 2025 21:40:52 +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 1v8mlH-002wVO-Jv for pgsql-general@arkaria.postgresql.org; Tue, 14 Oct 2025 21:40:50 +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 1v8mlH-002wVG-4n for pgsql-general@lists.postgresql.org; Tue, 14 Oct 2025 21:40:50 +0000 Received: from mail-vs1-xe2e.google.com ([2607:f8b0:4864:20::e2e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v8mlE-002C9H-05 for pgsql-general@lists.postgresql.org; Tue, 14 Oct 2025 21:40:49 +0000 Received: by mail-vs1-xe2e.google.com with SMTP id ada2fe7eead31-5d758dba570so361874137.2 for ; Tue, 14 Oct 2025 14:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidbarsky.com; s=google; t=1760478046; x=1761082846; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GlJwPO4LfaD2HE3kYkPShjKu0IMi0BMUhhNkUfcQn0c=; b=bV+GtW9GKHGOgHDIgMGTo8Pqt3LSvR5Edq6oCqbnaspe5XneuctQJJ99v013ILa2pK 5sCsttvxHn6pK8ekCeFX2nUS4OStFNzIpaTcZLDeWCyiiuME9AkKQR3aTEa9D3qbV0l8 D+km/BpGATZYSCT0R/7aSRQHKX2kKIv4iR0QYAyJc7BU3nFe9aQmA5xt7Q8LyF+JZDm2 ajxvzmvdbjd7IYSXeqVm/FsIjaNdDSIceeyCahZ/00GLfuM+xWe7Q/CO8j7nMzsw7Zkw B1XH5LpU6gdhMMZg9PMRUfUNNUq24YaPkeB4MLAoM7UUMJdouh0wI8Z79So1xFtdBu+1 /spw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760478046; x=1761082846; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GlJwPO4LfaD2HE3kYkPShjKu0IMi0BMUhhNkUfcQn0c=; b=Tz14ysXDhPS3fnOgekhIPFu8O633DTo49jaToWtITCQNo0T5d+QkaaB0yCKQW7wETa qmld6VbehepzdQhqY6hlBdJgcZDyt3YRONmwdKBzg9DPPnYKx8hyJKT0DVeTK5W8iBpR 5l39UZXnkNoK3xkcaIPNHX+nPT7Wv070AI6oQsf2jCvb9/cz7BwuLUukA0lqfyBqNdcG rjDWxSsIA3D0RH16ep2MSOQygknqQ/HBcujfsXE6RhHLAcRRBL0oxvYWX0sBsAq2lksN f0gMnRXUYbtTzt34D6fPn/LOCtP9swOalPMmjwdE7vhwb+6JhxonA4+KCwHq5YLlpXul b3vQ== X-Gm-Message-State: AOJu0Yxs3air2K9yekcpIbkoT5l6nH4Mcfq4adyYgr2brSMDvEXet+qp YP/BjjtkMc1cVBZYVxbegz3HXx0EnYTiMhuiMCdlC5UWA5AKGl3lWcz1ze7lpnN4m2Aa7wnL13y sihjdoO1zusYwNBQLaLaN0lnw/bSvPezflbiA7wDQig== X-Gm-Gg: ASbGncuiJ7QIhR0PXemeQyFGlr3BbdY6IwG5JgHUXwZjlBy/vVxvKFKTJLapgaVK8HC 4k/IRLhlp8hx58wfo0DayvcAm3WxVbdx1BCDs8/rgoqAZnP4HBiKXYjGMvX/0we5VDYHi3Otbk7 bxWLJ/YKsYfuDd+ST45uQGbzZoshY5rcqzxf1v058YafF+sbQ/ltSyLr9ELPzOIbmcUvxQ+HmHh NEh2FYIJNo6S8RVyrUMe0AtWqmpyPRGIOu/B9v2WvhaVS/40iS1Sr60bNg+XQIFjvmo2Q== X-Google-Smtp-Source: AGHT+IEaxEPKFqAHDUzoBekjgwNFdal3+JNm/qHSnX+9EfQ6p8WiYfOkQJylWjEpnAKKThpA+vmL0+2IpMe0NG2yNrA= X-Received: by 2002:a05:6102:6ca:b0:5d5:f6ae:38de with SMTP id ada2fe7eead31-5d5f6ae3c7cmr6354501137.41.1760478045778; Tue, 14 Oct 2025 14:40:45 -0700 (PDT) Received: from 1064022179695 named unknown by gmailapi.google.com with HTTPREST; Tue, 14 Oct 2025 14:40:45 -0700 Received: from 1064022179695 named unknown by gmailapi.google.com with HTTPREST; Tue, 14 Oct 2025 14:40:42 -0700 MIME-Version: 1.0 (Mimestream 1.8.3) References: <73ff46d2-0bad-4a8d-9928-e494c2d5b0d1@gmail.com> <93702.1760321769@sss.pgh.pa.us> <233155.1760369829@sss.pgh.pa.us> In-Reply-To: From: David Barsky Date: Tue, 14 Oct 2025 14:40:45 -0700 X-Gm-Features: AS18NWDyCfSto3B91EpIEcogv1vEKR1LF5UBI84B3GD0scdNYlPEDvAmlAcwUMM Message-ID: Subject: Re: Option on `postgres` CLI to shutdown when there are no more active connections? To: Ron Johnson Cc: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000008dc2c00641253c1b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000008dc2c00641253c1b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > If testing is all scripted, then why not put "pg_ctl stop" at the end of the script? Sorry for the delay. It=E2=80=99s _mostly_ scripted, but two major reasons: 1. If that script is cancelled or interrupted for any reason, it=E2=80=99s = possible that `pg_ctl stop` won't be called and I'd have a leaked process. I could mitigate this by calling `pg_ctl stop` at the *start* of the script, but that adds a bit of latency I'd prefer to avoid. 2. It's a pain to hook that script up to our IDEs in a semi-centralized manner (I extended rust-analyzer's test runner to support non-standard build systems and I never really got non-standard build systems working with debuggers). Even if we eat the pain, the aforementioned latency coming from `pg_ctl stop` is a bit annoying. 1. For context, rust-analyzer has a nice "runnables" feature that makes it possible to run a test directly from within an IDE. Other language servers/IDEs have similar functionality, but they're heavily biased to use language-idiomatic tools and make it a pain to override build tools/runnables. Besides, in my experience working on IDEs for a larg= e tech company (and collecting a _lot_ of logs/telemetry...), it's _extremely_ rare for people to configure their editors: they're overwhelmingly stock. I'm also of the mind that there's some elegance to `pg_ctl start --exit-mode=3Dsmart`: no matter how the test script is interrupted or cancelled, I can run it again and guarantee that there will be *no* leaked processes or non-idempotency because the postmaster handles it. That said, looking over the `postmaster.c` source, it seems like there isn't any bookkeeping of childre= n starting/exiting, so there isn't really any reference counting of connections there. I'd be happy to add it, but I _do not_ trust myself to write correct C! Anyways, I think this relatively small tweak can make a pretty meaningful impact in the end-developer experience of programming against Postgres, especially in setups that would like to minimize cross-language scripting/dependencies. However, I also understand that this isn't exactly how Postgres might be commonly used on these mailing lists. =E2=80=94David On Oct 13, 2025 at 1:27:17=E2=80=AFPM, Ron Johnson wrote: > On Mon, Oct 13, 2025 at 3:19=E2=80=AFPM David Barsky = wrote: > [snip] > >> Anyways, I'll try to get at what motivated this whole discussion: would >> there be >> community opposition to adding a CLI flag that'd exit/shutdown all >> Postgres >> processes once all pending connections close? E.g., something similar to >> SQL >> Server's `auto_close` in the vein of `postgres >> -c "auto_close_after=3D100"` or `pg-ctl start --exit-mode=3Dsmart`? >> > > If testing is all scripted, then why not put "pg_ctl stop" at the end of > the script? > > -- > Death to , and butter sauce. > Don't boil me, I'm still alive. > lobster! > --0000000000008dc2c00641253c1b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> If testing is all scripted, then why not = put "pg_ctl stop" at the end of the script?

Sorry for the delay.

<= /div>
It=E2=80=99s _mostly_ scripted, but two major reasons= :

1. If that script is can= celled or interrupted for any reason, it=E2=80=99s possible that
=C2=A0 =C2=A0`pg_ctl stop` won't be called and I'd have= a leaked process. 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.
2. It's a pain to hook that script up to our IDEs in= a semi-centralized manner
=C2=A0 =C2=A0(I extended r= ust-analyzer's test runner to support non-standard build systems
<= div dir=3D"ltr">=C2=A0 =C2=A0and I never really got non-standard build syst= ems working with debuggers).
=C2=A0 =C2=A0Even if we = eat the pain, the aforementioned latency coming from `pg_ctl stop`
=C2=A0 =C2=A0is a bit annoying.
=C2=A0 = =C2=A01. For context, rust-analyzer has a nice "runnables" featur= e that makes it
=C2=A0 =C2=A0 =C2=A0 possible to run = a test directly from within an IDE. Other language
= =C2=A0 =C2=A0 =C2=A0 servers/IDEs have similar functionality, but they'= re heavily biased to use
=C2=A0 =C2=A0 =C2=A0 languag= e-idiomatic tools and make it a pain to override build
=C2=A0 =C2=A0 =C2=A0 tools/runnables. Besides, in my experience working o= n IDEs for a large
=C2=A0 =C2=A0 =C2=A0 tech company = (and collecting a _lot_ of logs/telemetry...), it's
=C2=A0 =C2=A0 =C2=A0 _extremely_ rare for people to configure their edit= ors: they're
=C2=A0 =C2=A0 =C2=A0 overwhelmingly = stock.

I'm also of the= mind that there's some elegance to `pg_ctl start
--exit-mode=3Dsmart`: no matter how the test script is interrupted or canc= elled, I
can run it again and guarantee that there wi= ll be *no* leaked processes or
non-idempotency becaus= e the postmaster handles it. That said, looking over the
`postmaster.c` source, it seems like there isn't any bookkeeping of= children
starting/exiting, so there isn't really= any reference counting of connections
there. I'd= be happy to add it, but I _do not_ trust myself to write correct C!
<= div dir=3D"ltr">
Anyways, I think this relatively= small tweak can make a pretty meaningful impact
in t= he end-developer experience of programming against Postgres, especially in<= /div>
setups that would like to minimize cross-language scr= ipting/dependencies.
However, I also understand that = this isn't exactly how Postgres might be
commonly= used on these mailing lists.

=E2=80=94David

On Oct 13, 2025 at 1:27:17=E2=80= =AFPM, Ron Johnson <ronljohns= onjr@gmail.com> wrote:
On Mon, Oct 13, 2025 at 3:19=E2= =80=AFPM David Barsky <me@davidbar= sky.com> wrote:
=
Anyways, I= 9;ll try to get at what motivated this whole discussion: would there be
community opposition to adding a CLI flag that'd exi= t/shutdown all Postgres
processes once all pending co= nnections close? E.g., something similar to SQL
Serve= r's `auto_close` in the vein of `postgres
-c &quo= t;auto_close_after=3D100"` or `pg-ctl start --exit-mode=3Dsmart`?

= If testing is all scripted, then why not put "pg_ctl stop" at the= end of the script?

--
Death to <Redacted>, and butter sauce.
Don't boil me, I= 9;m still alive.
<Redacted> lobster!
=20
--0000000000008dc2c00641253c1b--