Re: Use proc_exit() in WalRcvWaitForStartPosition - Mailing list pgsql-hackers

From Xuneng Zhou
Subject Re: Use proc_exit() in WalRcvWaitForStartPosition
Date
Msg-id CABPTF7V=y2rHC=gLTeC-42aRc+jcXueomUBjbNiy3pOfhJs3_A@mail.gmail.com
Whole thread
In response to Re: Use proc_exit() in WalRcvWaitForStartPosition  (Andreas Karlsson <andreas@proxel.se>)
Responses Re: Use proc_exit() in WalRcvWaitForStartPosition
List pgsql-hackers
On Thu, Apr 9, 2026 at 5:00 AM Andreas Karlsson <andreas@proxel.se> wrote:
>
> On 4/8/26 11:08 AM, Chao Li wrote:
> > While working on another patch, I happened to notice that WalRcvWaitForStartPosition() calls raw exit(1). I think
thisshould use proc_exit(1) instead, so that the normal cleanup machinery is not bypassed. 
> >
> > This tiny patch just replaces exit(1) with proc_exit(1) in WalRcvWaitForStartPosition().
>
> This looks likely to be correct since when we exit in WalReceiverMain()
> (on WALRCV_STOPPING and WALRCV_STOPPED) we call proc_exit(1). I feel we
> should exit the same way in WalRcvWaitForStartPosition() as we do in
> WalReceiverMain() and if not I would like a comment explaining why those
> two cases are different.

+1

WalRcvWaitForStartPosition, WALRCV_STOPPING before entering wait loop
uses proc_exit(0) for WALRCV_STOPPING, while this path should probably
use proc_exit(0) as well (not proc_exit(1)), since the stop was a
requested shutdown, not an error. Using exit code 1 for a clean
stop-on-request seems inconsistent.

--
Best,
Xuneng



pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Add pg_stat_autovacuum_priority
Next
From: Chao Li
Date:
Subject: Re: pgstat vs aset