pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix resource leak when a FDW's ForeignAsyncRequest function fail 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix resource leak when a FDW's ForeignAsyncRequest function fail @ 2023-11-23 11:33 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 3+ messages in thread From: Heikki Linnakangas @ 2023-11-23 11:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix resource leak when a FDW's ForeignAsyncRequest function fails If an error is thrown after calling CreateWaitEventSet(), the memory of a WaitEventSet is free'd as it's allocated in the short-lived memory context, but the file descriptor (on epoll- or kqueue-based systems) or handles (on Windows) that it contains are leaked. Use PG_TRY-FINALLY to ensure it gets freed. (On master, I will apply a better fix, using ResourceOwners to track the WaitEventSet, but that's not backpatchable.) 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. Backpatch to v14 where async execution was introduced, but master gets a different fix. Discussion: https://www.postgresql.org/message-id/17828-122da8cba23236be@postgresql.org Discussion: https://www.postgresql.org/message-id/472235.1678387869@sss.pgh.pa.us Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/481d7d1c01c6335661dd2ccf505298e4b91ee12a Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 7 +++ contrib/postgres_fdw/sql/postgres_fdw.sql | 6 +++ src/backend/executor/nodeAppend.c | 66 +++++++++++++++----------- 3 files changed, 50 insertions(+), 29 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix resource leak when a FDW's ForeignAsyncRequest function fail @ 2023-11-23 11:33 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 3+ messages in thread From: Heikki Linnakangas @ 2023-11-23 11:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix resource leak when a FDW's ForeignAsyncRequest function fails If an error is thrown after calling CreateWaitEventSet(), the memory of a WaitEventSet is free'd as it's allocated in the short-lived memory context, but the file descriptor (on epoll- or kqueue-based systems) or handles (on Windows) that it contains are leaked. Use PG_TRY-FINALLY to ensure it gets freed. (On master, I will apply a better fix, using ResourceOwners to track the WaitEventSet, but that's not backpatchable.) 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. Backpatch to v14 where async execution was introduced, but master gets a different fix. Discussion: https://www.postgresql.org/message-id/17828-122da8cba23236be@postgresql.org Discussion: https://www.postgresql.org/message-id/472235.1678387869@sss.pgh.pa.us Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/501cfd07dac6dde5f8dae2d00fcf65d42e2caf80 Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 7 +++ contrib/postgres_fdw/sql/postgres_fdw.sql | 6 +++ src/backend/executor/nodeAppend.c | 66 +++++++++++++++----------- 3 files changed, 50 insertions(+), 29 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix resource leak when a FDW's ForeignAsyncRequest function fail @ 2023-11-23 11:33 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 3+ messages in thread From: Heikki Linnakangas @ 2023-11-23 11:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix resource leak when a FDW's ForeignAsyncRequest function fails If an error is thrown after calling CreateWaitEventSet(), the memory of a WaitEventSet is free'd as it's allocated in the short-lived memory context, but the file descriptor (on epoll- or kqueue-based systems) or handles (on Windows) that it contains are leaked. Use PG_TRY-FINALLY to ensure it gets freed. (On master, I will apply a better fix, using ResourceOwners to track the WaitEventSet, but that's not backpatchable.) 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. Backpatch to v14 where async execution was introduced, but master gets a different fix. Discussion: https://www.postgresql.org/message-id/17828-122da8cba23236be@postgresql.org Discussion: https://www.postgresql.org/message-id/472235.1678387869@sss.pgh.pa.us Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/555276f8594087ba15e0d58e38cd2186b9f39f6d Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 7 +++ contrib/postgres_fdw/sql/postgres_fdw.sql | 6 +++ src/backend/executor/nodeAppend.c | 66 +++++++++++++++----------- 3 files changed, 50 insertions(+), 29 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-11-23 11:33 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-11-23 11:33 pgsql: Fix resource leak when a FDW's ForeignAsyncRequest function fail Heikki Linnakangas <heikki.linnakangas@iki.fi> 2023-11-23 11:33 pgsql: Fix resource leak when a FDW's ForeignAsyncRequest function fail Heikki Linnakangas <heikki.linnakangas@iki.fi> 2023-11-23 11:33 pgsql: Fix resource leak when a FDW's ForeignAsyncRequest function fail Heikki Linnakangas <heikki.linnakangas@iki.fi>
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