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

Commite731e9d

Browse files
committed
Handle interrupts while waiting on Append's async subplans
We did not wake up on interrupts while waiting on async events on anasync-capable append node. For example, if you tried to cancel thequery, nothing would happen until one of the async subplans becomesreadable. To fix, add WL_LATCH_SET to the WaitEventSet.Backpatch down to v14 where async Append execution was introduced.Discussion:https://www.postgresql.org/message-id/37a40570-f558-40d3-b5ea-5c2079b3b30b@iki.fi
1 parentca0830e commite731e9d

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

‎src/backend/executor/nodeAppend.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ ExecAppendAsyncRequest(AppendState *node, TupleTableSlot **result)
10161016
staticvoid
10171017
ExecAppendAsyncEventWait(AppendState*node)
10181018
{
1019-
intnevents=node->as_nasyncplans+1;
1019+
intnevents=node->as_nasyncplans+2;
10201020
longtimeout=node->as_syncdone ?-1 :0;
10211021
WaitEventoccurred_event[EVENT_BUFFER_SIZE];
10221022
intnoccurred;
@@ -1041,8 +1041,8 @@ ExecAppendAsyncEventWait(AppendState *node)
10411041
}
10421042

10431043
/*
1044-
* No need for further processing ifthere are noconfiguredevents other
1045-
*than the postmaster death event.
1044+
* No need for further processing ifnone of the subplansconfiguredany
1045+
*events.
10461046
*/
10471047
if (GetNumRegisteredWaitEvents(node->as_eventset)==1)
10481048
{
@@ -1051,6 +1051,21 @@ ExecAppendAsyncEventWait(AppendState *node)
10511051
return;
10521052
}
10531053

1054+
/*
1055+
* Add the process latch to the set, so that we wake up to process the
1056+
* standard interrupts with CHECK_FOR_INTERRUPTS().
1057+
*
1058+
* NOTE: For historical reasons, it's important that this is added to the
1059+
* WaitEventSet after the ExecAsyncConfigureWait() calls. Namely,
1060+
* postgres_fdw calls "GetNumRegisteredWaitEvents(set) == 1" to check if
1061+
* any other events are in the set. That's a poor design, it's
1062+
* questionable for postgres_fdw to be doing that in the first place, but
1063+
* we cannot change it now. The pattern has possibly been copied to other
1064+
* extensions too.
1065+
*/
1066+
AddWaitEventToSet(node->as_eventset,WL_LATCH_SET,PGINVALID_SOCKET,
1067+
MyLatch,NULL);
1068+
10541069
/* Return at most EVENT_BUFFER_SIZE events in one call. */
10551070
if (nevents>EVENT_BUFFER_SIZE)
10561071
nevents=EVENT_BUFFER_SIZE;
@@ -1092,6 +1107,13 @@ ExecAppendAsyncEventWait(AppendState *node)
10921107
ExecAsyncNotify(areq);
10931108
}
10941109
}
1110+
1111+
/* Handle standard interrupts */
1112+
if ((w->events&WL_LATCH_SET)!=0)
1113+
{
1114+
ResetLatch(MyLatch);
1115+
CHECK_FOR_INTERRUPTS();
1116+
}
10951117
}
10961118
}
10971119

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp