Re: Use-after-free issue in postgres_fdw

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Etsuro Fujita <etsuro.fujita@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-27T08:07:02Z
Lists: pgsql-hackers
On Fri, Apr 24, 2026 at 01:59:22AM -0700, Etsuro Fujita wrote:
> I added a simple SQL test, not an isolation one.  Attached is an
> updated patch for that.  The basic idea for the test is the same as
> the one I showed upthread, but the test ensures the order by checking
> for the termination by using pg_stat_activity.  In the patch I added a
> comment for pgfdw_reject_incomplete_xact_state_change() as well.

Smart.

> Right, this patch delays discarding the failed connection until abort
> cleanup of the top transaction, so it is guaranteed that anyone that
> uses it can safely refer to its PGconn when needed.

+-- test handling of abort-cleanup-failed connections

Perhaps this could be more descriptive, like "test cleanup of failed
connections on abort"?
--
Michael

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. postgres_fdw: Fix handling of abort-cleanup-failed connections.