Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit700e8fe

Browse files
author
Etsuro Fujita
committed
postgres_fdw: Fix subabort cleanup of connections used in asynchronous execution.
Commit27e1f14 resets the per-connection states of connections used toscan foreign tables asynchronously during abort cleanup at maintransaction end, but it failed to do so during subabort cleanup atsubtransaction end, leading to a segmentation fault when re-executing anasynchronous-foreign-table-scan query in a transaction that wascancelled in a subtransaction of it.Fix by modifying pgfdw_abort_cleanup() to reset the per-connection stateof a given connection also when called for subabort cleanup. Also,modify that function to do the reset in both the abort-cleanup andsubabort-cleanup cases if necessary, to save cycles, and improve acomment on it a little bit.Back-patch to v14 where the aforesaid commit came in.Reviewed by Alexander PyhalovDiscussion:https://postgr.es/m/CAPmGK14cCV-JA7kNsyt2EUTKvZ4xkr2LNRthi1U1C3cqfGppAw@mail.gmail.com
1 parent84db516 commit700e8fe

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

‎contrib/postgres_fdw/connection.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,17 @@ pgfdw_xact_callback(XactEvent event, void *arg)
977977
{
978978
entry->have_prep_stmt= false;
979979
entry->have_error= false;
980-
/* Also reset per-connection state */
981-
memset(&entry->state,0,sizeof(entry->state));
980+
981+
/*
982+
* If pendingAreq of the per-connection state is not
983+
* NULL, it means that an asynchronous fetch begun by
984+
* fetch_more_data_begin() was not done successfully
985+
* and thus the per-connection state was not reset in
986+
* fetch_more_data(); in that case reset the
987+
* per-connection state here.
988+
*/
989+
if (entry->state.pendingAreq)
990+
memset(&entry->state,0,sizeof(entry->state));
982991
}
983992

984993
/* Disarm changing_xact_state if it all worked. */
@@ -1109,6 +1118,19 @@ pgfdw_subxact_callback(SubXactEvent event, SubTransactionId mySubid,
11091118
curlevel,curlevel);
11101119
if (!pgfdw_exec_cleanup_query(entry->conn,sql, false))
11111120
abort_cleanup_failure= true;
1121+
else
1122+
{
1123+
/*
1124+
* If pendingAreq of the per-connection state is not NULL,
1125+
* it means that an asynchronous fetch begun by
1126+
* fetch_more_data_begin() was not done successfully and
1127+
* thus the per-connection state was not reset in
1128+
* fetch_more_data(); in that case reset the
1129+
* per-connection state here.
1130+
*/
1131+
if (entry->state.pendingAreq)
1132+
memset(&entry->state,0,sizeof(entry->state));
1133+
}
11121134
}
11131135

11141136
/* Disarm changing_xact_state if it all worked. */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp