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

Commit42d3649

Browse files
committed
Ensure that plpgsql cleans up cleanly during parallel-worker exit.
plpgsql_xact_cb ought to treat events XACT_EVENT_PARALLEL_COMMIT andXACT_EVENT_PARALLEL_ABORT like XACT_EVENT_COMMIT and XACT_EVENT_ABORTrespectively, since its goal is to do process-local cleanup. Thisoversight caused plpgsql's end-of-transaction cleanup to not get donein parallel workers. Since a parallel worker will exit just after thetransaction cleanup, the effects of this are limited. I couldn't findany case in the core code with user-visible effects, but perhaps thereare some in extensions. In any case it's wrong, so let's fix it beforeit bites us not after.In passing, add some comments around the handling of expressionevaluation resources in DO blocks. There's no live bug there, but it'squite unobvious what's happening; at least I thought so. This isn'trelated to the other issue, except that I found both things while pokingat expression-evaluation performance.Back-patch the plpgsql_xact_cb fix to 9.5 where those event typeswere introduced, and the DO-block commentary to v11 where DO blocksgained the ability to issue COMMIT/ROLLBACK.Discussion:https://postgr.es/m/10353.1585247879@sss.pgh.pa.us
1 parentf36a104 commit42d3649

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7117,7 +7117,9 @@ plpgsql_xact_cb(XactEvent event, void *arg)
71177117
* expect the regular abort recovery procedures to release everything of
71187118
* interest.
71197119
*/
7120-
if (event==XACT_EVENT_COMMIT||event==XACT_EVENT_PREPARE)
7120+
if (event==XACT_EVENT_COMMIT||
7121+
event==XACT_EVENT_PARALLEL_COMMIT||
7122+
event==XACT_EVENT_PREPARE)
71217123
{
71227124
/* Shouldn't be any econtext stack entries left at commit */
71237125
Assert(simple_econtext_stack==NULL);
@@ -7126,7 +7128,8 @@ plpgsql_xact_cb(XactEvent event, void *arg)
71267128
FreeExecutorState(shared_simple_eval_estate);
71277129
shared_simple_eval_estate=NULL;
71287130
}
7129-
elseif (event==XACT_EVENT_ABORT)
7131+
elseif (event==XACT_EVENT_ABORT||
7132+
event==XACT_EVENT_PARALLEL_ABORT)
71307133
{
71317134
simple_econtext_stack=NULL;
71327135
shared_simple_eval_estate=NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp