pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use ResourceOwner to track WaitEventSets.
Date: Thu, 23 Nov 2023 11:33:23 +0000
Message-ID: <E1r67xS-006q0v-SZ@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/50c67c2019ab9ade8aa8768bfe604cd802fe8591

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out |  7 +++
contrib/postgres_fdw/sql/postgres_fdw.sql      |  6 +++
src/backend/executor/nodeAppend.c              |  5 +-
src/backend/libpq/pqcomm.c                     |  2 +-
src/backend/postmaster/postmaster.c            |  2 +-
src/backend/postmaster/syslogger.c             |  2 +-
src/backend/storage/ipc/latch.c                | 68 +++++++++++++++++++++++---
src/include/storage/latch.h                    |  4 +-
src/include/utils/resowner.h                   |  1 +
9 files changed, 84 insertions(+), 13 deletions(-)



Message-ID: <E1r67xS-006q0v-SZ@gemulon.postgresql.org>
Permalink:  ../E1r67xS-006q0v-SZ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1r67xS-006q0v-SZ@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Use ResourceOwner to track WaitEventSets.
  In-Reply-To: <E1r67xS-006q0v-SZ@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox