pgsql: postgres_fdw: Fix subabort cleanup of connections used in asynch

From: Etsuro Fujita <efujita(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: postgres_fdw: Fix subabort cleanup of connections used in asynch
Date: 2022-01-21 08:54:27
Message-ID: E1nApgh-00041N-Ms@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

postgres_fdw: Fix subabort cleanup of connections used in asynchronous execution.

Commit 27e1f1456 resets the per-connection states of connections used to
scan foreign tables asynchronously during abort cleanup at main
transaction end, but it failed to do so during subabort cleanup at
subtransaction end, leading to a segmentation fault when re-executing an
asynchronous-foreign-table-scan query in a transaction that was
cancelled in a subtransaction of it.

Fix by modifying pgfdw_abort_cleanup() to reset the per-connection state
of a given connection also when called for subabort cleanup. Also,
modify that function to do the reset in both the abort-cleanup and
subabort-cleanup cases if necessary, to save cycles, and improve a
comment on it a little bit.

Back-patch to v14 where the aforesaid commit came in.

Reviewed by Alexander Pyhalov

Discussion: https://postgr.es/m/CAPmGK14cCV-JA7kNsyt2EUTKvZ4xkr2LNRthi1U1C3cqfGppAw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6c07f9ebce1579612c4ed9076159f9e942e50f9d

Modified Files
--------------
contrib/postgres_fdw/connection.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2022-01-21 19:49:31 pgsql: fsync pg_logical/mappings in CheckPointLogicalRewriteHeap().
Previous Message Michael Paquier 2022-01-21 05:55:40 pgsql: Fix one-off bug causing missing commit timestamps for subtransac