Re: Return value of pg_promote()

From: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Return value of pg_promote()
Date: 2023-08-28 06:20:45
Message-ID: CAE9k0Pnn5_YFtZPXFC2baB6x1c9x+Gq4wW6NtXm66SVHxsNAUA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Michael,

On Thu, Aug 17, 2023 at 6:07 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Wed, Aug 16, 2023 at 05:02:09PM +0900, Michael Paquier wrote:
> > if (kill(PostmasterPid, SIGUSR1) != 0)
> > {
> > - ereport(WARNING,
> > - (errmsg("failed to send signal to postmaster: %m")));
> > (void) unlink(PROMOTE_SIGNAL_FILE);
> > - PG_RETURN_BOOL(false);
> > + ereport(ERROR,
> > + (errmsg("failed to send signal to postmaster: %m")));
> > }
> >
> > Shouldn't you assign an error code to this one rather than the
> > default one for internal errors, like ERRCODE_SYSTEM_ERROR?
> >
> > /* return immediately if waiting was not requested */
> > @@ -744,7 +743,9 @@ pg_promote(PG_FUNCTION_ARGS)
> > * necessity for manual cleanup of all postmaster children.
> > */
> > if (rc & WL_POSTMASTER_DEATH)
> > - PG_RETURN_BOOL(false);
> > + ereport(FATAL,
> > + (errcode(ERRCODE_ADMIN_SHUTDOWN),
> > + errmsg("terminating connection due to unexpected postmaster exit")));
> >
> > I would add an errcontext here, to let somebody know that the
> > connection died while waiting for the promotion to be processed, say
> > "while waiting on promotion".
>
> I have just noticed that we do not have a CF entry for this proposal,
> so I have added one with Laurenz as author:
> https://commitfest.postgresql.org/44/4504/
>
> For now the patch is waiting on author. Could you address my
> last review?

Thanks for reviewing the patch and adding a CF entry for it. PFA patch
that addresses your review comments.

And... Sorry for the delayed response. I totally missed it.

--
With Regards,
Ashutosh Sharma.

Attachment Content-Type Size
v2-error-out-in-case-pg_promote-unable-to-send-SIGUSR1-to-postmaster.patch application/octet-stream 1.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-08-28 06:44:25 Re: Convert encrypted SSL test keys to PKCS#8 format
Previous Message Erik Rijkers 2023-08-28 06:09:44 https://git.postgresql.org/git/postgresql.git/ fails