Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o - Mailing list pgsql-committers

From Andres Freund
Subject Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o
Date
Msg-id 20210807051149.x2j3n64ejcu23hm4@alap3.anarazel.de
Whole thread Raw
In response to Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o  (Andres Freund <andres@anarazel.de>)
Responses Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-committers
Hi,

On 2021-08-06 21:49:52 -0700, Andres Freund wrote:
> The temp file is created by InitializeBackupManifest(). In the !OSX case, we
> first abort via an ERROR, which triggers the cleanup via
> WalSndResourceCleanup(). On OSX however, we immediately error out with FATAL
> for some reason (timing? network buffering differences?), which will never
> reach WalSndErrorCleanup(). Therefore the temp file only gets deleted during
> proc_exit(), which triggers the issue...
> 
> Not yet really sure what the best way to deal with this is. Presumably this
> issue would be fixed if AtProcExit_Files()/CleanupTempFiles() were scheduled
> via before_shmem_exit(). And perhaps it's not too off to schedule
> CleanupTempFiles() there - but it doesn't quite seem entirely right either.

Huh. I just noticed that AtProcExit_Files() is not even scheduled via
on_shmem_exit() but on_proc_exit().  That means that even before fb2c5028e63
we sent pgstat messages *well* after pgstat_shutdown_hook() already
ran. Crufty.

Just hacking in an earlier CleanupTempFiles() does "fix" the OSX issue:
https://cirrus-ci.com/task/5941265494704128?logs=macos_basebackup#L4

I'm inclined to leave things as-is until tomorrow to see if other things are
shaken loose and then either commit a bandaid along those lines or revert the
patch. Or something proper if we can figure it out till then.

Greetings,

Andres Freund



pgsql-committers by date:

Previous
From: Andres Freund
Date:
Subject: Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o
Next
From: Peter Eisentraut
Date:
Subject: pgsql: Message style improvements