postgresql/src/backend/postmaster
Heikki Linnakangas 50c67c2019 Use ResourceOwner to track WaitEventSets.
A WaitEventSet holds file descriptors or event handles (on Windows).
If FreeWaitEventSet is not called, those fds or handles are leaked.
Use ResourceOwners to track WaitEventSets, to clean those up
automatically on error.

This was a live bug in async Append nodes, if a FDW's
ForeignAsyncRequest function failed. (In back branches, I will apply a
more localized fix for that based on PG_TRY-PG_FINALLY.)

The added test doesn't check for leaking resources, so it passed even
before this commit. But at least it covers the code path.

In the passing, fix misleading comment on what the 'nevents' argument
to WaitEventSetWait means.

Report by Alexander Lakhin, analysis and suggestion for the fix by
Tom Lane. Fixes bug #17828.

Reviewed-by: Alexander Lakhin, Thomas Munro
Discussion: https://www.postgresql.org/message-id/472235.1678387869@sss.pgh.pa.us
2023-11-23 13:31:36 +02:00
..
Makefile Redesign archive modules 2023-02-17 14:26:42 +09:00
autovacuum.c Retire MemoryContextResetAndDeleteChildren() macro. 2023-11-15 13:42:30 -06:00
auxprocess.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
bgworker.c Rename StartBackgroundWorker() to BackgroundWorkerMain(). 2023-10-09 11:52:09 +03:00
bgwriter.c Retire MemoryContextResetAndDeleteChildren() macro. 2023-11-15 13:42:30 -06:00
checkpointer.c Retire MemoryContextResetAndDeleteChildren() macro. 2023-11-15 13:42:30 -06:00
fork_process.c Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
interrupt.c Perform apply of large transactions by parallel workers. 2023-01-09 07:52:45 +05:30
meson.build Redesign archive modules 2023-02-17 14:26:42 +09:00
pgarch.c Redesign archive modules 2023-02-17 14:26:42 +09:00
postmaster.c Use ResourceOwner to track WaitEventSets. 2023-11-23 13:31:36 +02:00
startup.c Avoid calling proc_exit() in processes forked by system(). 2023-10-17 10:41:48 -05:00
syslogger.c Use ResourceOwner to track WaitEventSets. 2023-11-23 13:31:36 +02:00
walwriter.c Retire MemoryContextResetAndDeleteChildren() macro. 2023-11-15 13:42:30 -06:00