Re: Issue with cancel_before_shmem_exit while searching to remove a particular registered exit callbacks

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Issue with cancel_before_shmem_exit while searching to remove a particular registered exit callbacks
Date: 2020-08-10 19:50:19
Message-ID: CA+Tgmoaz=e0CEOVpFTMRtanXX+0P-1uRrYtKdWktQedLtGs6Qg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 10, 2020 at 3:41 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> > Perhaps we really have four categories here:
> > (1) Temporary handlers for PG_ENSURE_ERROR_CLEANUP().
> > (2) High-level cleanup that needs to run after aborting out of the
> > current transaction.
> > (3) Per-subsystem shutdown for shared memory stuff.
> > (4) Per-subsystem shutdown for backend-private stuff.
>
> Hmm, I don't think we actually have any of (2) do we? Or at least
> we aren't using ipc.c callbacks for them.

Well, I was thinking about the place where ShutdownPostgres() does
LockReleaseAll(), and also the stuff in RemoveTempRelationsCallback().
Those are pretty high-level operations that need to happen before we
start shutting down subsystems. Especially the removal of temp
relations.

> > What I do think we should do, after thinking about it more,
> > is discourage the casual use of before_shmem_exit() for things where
> > on_shmem_exit() or on_proc_exit() would be just as good. I think
> > that's what would avoid the most problems here.
>
> I think we're mostly in violent agreement here. The interesting
> question seems to be Andres' one about whether before_shmem_exit
> actually has any safe use except for PG_ENSURE_ERROR_CLEANUP.
> It may not, in which case perhaps we oughta rename it?

If we could eliminate the other places where it's used, that'd be
great. That's not too clear to me, though, because of the above two
cases.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2020-08-10 19:51:03 Re: nested queries vs. pg_stat_activity
Previous Message Tom Lane 2020-08-10 19:41:33 Re: Issue with cancel_before_shmem_exit while searching to remove a particular registered exit callbacks