Re: elog(FATAL) vs shared memory - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: elog(FATAL) vs shared memory
Date
Msg-id 874pnl1w38.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: elog(FATAL) vs shared memory  (Heikki Linnakangas <heikki@enterprisedb.com>)
List pgsql-hackers
"Heikki Linnakangas" <heikki@enterprisedb.com> writes:

> Tom Lane wrote:
>
>> AFAICS, there are basically two ways we might try to approach this:
>>
>> Plan A: establish the rule that you mustn't try to clean up shared
>> memory state in a PG_CATCH block.  Anything you need to do like that
>> has to be handled by an on_shmem_exit hook function, so it will be
>> called during a FATAL exit.  (Or maybe you can do it in PG_CATCH for
>> normal ERROR cases, but you need a backing on_shmem_exit hook to
>> clean up for FATAL.)
>>...
>> So Plan B seems unacceptably fragile.  Does anyone see a way to fix it,
>> or perhaps a Plan C with a totally different idea?  Plan A seems pretty
>> ugly but it's the best I can come up with.
>
> Yeah, plan A seems like the way to go.

The alternative is that instead of a general purpose shmem hook you note the
pid of the process that is expecting to handle the cleanup. So for instance
something like pg_start_backup instead of setting a flag would store its pid.
Then someone else who comes along and finds the field set has to double check
if the pid is actually still around and if not it has to clean it up itself.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: "Jonah H. Harris"
Date:
Subject: Re: Benchmarking tools for the Postgres, EDB and Oracle Database
Next
From: Gregory Stark
Date:
Subject: Re: Makefile patch to make gcov work on Postgres contrib modules