Re: Is abort() still needed in WalSndShutdown()?

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Is abort() still needed in WalSndShutdown()?
Date: 2026-01-26 09:52:58
Message-ID: CAHGQGwGzMNJ5u5xpW6wmaY=Dxj7QyHh8XhnyAyyB63rGb+r09w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 23, 2026 at 9:30 PM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>
> On 23/01/2026 14:13, Fujii Masao wrote:
> > Hi,
> >
> > While reviewing the patch [1], I found that WalSndShutdown() calls abort()
> > with the comment "keep the compiler quiet" just after proc_exit(0).
> >
> > static void
> > WalSndShutdown(void)
> > {
> > /*
> > * Reset whereToSendOutput to prevent ereport from attempting to send any
> > * more messages to the standby.
> > */
> > if (whereToSendOutput == DestRemote)
> > whereToSendOutput = DestNone;
> >
> > proc_exit(0);
> > abort(); /* keep the compiler quiet */
> > }
> >
> > This may have been necessary in the past, but is it still required?
> > Other functions, such as CheckpointerMain(), simply call proc_exit(0)
> > without an abort(), which doesn't seem to cause compiler warnings.
> > That made me wonder whether the abort() in WalSndShutdown() is
> > still needed, or which compiler would actually warn if WalSndLoop()
> > does not end with an abort().
>
> Seems useless to me. Looking at the git history, long time ago the
> proc_exit(0) call was in a function that returned "int", and I can see
> how the compiler would complain about that if it didn't know that the
> function doesn't return. But WalSendShutdown() returns void these days,
> so you should not get a compiler warning, whether or not the compiler
> understands that proc_exit(0) doesn't return.

Thanks! Also WalSndShutdown() and proc_exit() are now marked pg_noreturn,
so the compiler can see that the function never returns, seems which should
also eliminate the warning even without abort().

I'm thinking to remove the abort() call from WalSndShutdown() in the
attached patch.

Regards,

--
Fujii Masao

Attachment Content-Type Size
v1-0001-Remove-unnecessary-abort-from-WalSndShutdown.patch application/octet-stream 1.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2026-01-26 10:05:49 Re: Safer hash table initialization macro
Previous Message Zsolt Parragi 2026-01-26 09:51:02 Re: Custom oauth validator options