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

Commit9dca62e

Browse files
committed
Fix logic for adding "parallel worker" context line to worker errors.
The previous coding here was capable of adding a "parallel worker" contextline to errors that were not, in fact, returned from a parallel worker.Instead of using an errcontext callback to add that annotation, just pasteit onto the message by hand; this looks uglier but is more reliable.Discussion: <19757.1472151987@sss.pgh.pa.us>
1 parente6bd440 commit9dca62e

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

‎src/backend/access/transam/parallel.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ static dlist_head pcxt_list = DLIST_STATIC_INIT(pcxt_list);
108108

109109
/* Private functions. */
110110
staticvoidHandleParallelMessage(ParallelContext*pcxt,inti,StringInfomsg);
111-
staticvoidParallelErrorContext(void*arg);
112111
staticvoidParallelExtensionTrampoline(dsm_segment*seg,shm_toc*toc);
113112
staticvoidParallelWorkerMain(Datummain_arg);
114113
staticvoidWaitForParallelWorkersToExit(ParallelContext*pcxt);
@@ -788,30 +787,43 @@ HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
788787
case'N':/* NoticeResponse */
789788
{
790789
ErrorDataedata;
791-
ErrorContextCallbackerrctx;
792790
ErrorContextCallback*save_error_context_stack;
793791

794-
/*
795-
* Rethrow the error using the error context callbacks that
796-
* were in effect when the context was created, not the
797-
* current ones.
798-
*/
799-
save_error_context_stack=error_context_stack;
800-
errctx.callback=ParallelErrorContext;
801-
errctx.arg=NULL;
802-
errctx.previous=pcxt->error_context_stack;
803-
error_context_stack=&errctx;
804-
805792
/* Parse ErrorResponse or NoticeResponse. */
806793
pq_parse_errornotice(msg,&edata);
807794

808795
/* Death of a worker isn't enough justification for suicide. */
809796
edata.elevel=Min(edata.elevel,ERROR);
810797

811-
/* Rethrow error or notice. */
798+
/*
799+
* If desired, add a context line to show that this is a
800+
* message propagated from a parallel worker. Otherwise, it
801+
* can sometimes be confusing to understand what actually
802+
* happened. (We don't do this in FORCE_PARALLEL_REGRESS mode
803+
* because it causes test-result instability depending on
804+
* whether a parallel worker is actually used or not.)
805+
*/
806+
if (force_parallel_mode!=FORCE_PARALLEL_REGRESS)
807+
{
808+
if (edata.context)
809+
edata.context=psprintf("%s\n%s",edata.context,
810+
_("parallel worker"));
811+
else
812+
edata.context=pstrdup(_("parallel worker"));
813+
}
814+
815+
/*
816+
* Context beyond that should use the error context callbacks
817+
* that were in effect when the ParallelContext was created,
818+
* not the current ones.
819+
*/
820+
save_error_context_stack=error_context_stack;
821+
error_context_stack=pcxt->error_context_stack;
822+
823+
/* Rethrow error or print notice. */
812824
ThrowErrorData(&edata);
813825

814-
/*Restoreprevious context. */
826+
/*Not an error, so restoreprevious context stack. */
815827
error_context_stack=save_error_context_stack;
816828

817829
break;
@@ -1112,18 +1124,6 @@ ParallelExtensionTrampoline(dsm_segment *seg, shm_toc *toc)
11121124
entrypt(seg,toc);
11131125
}
11141126

1115-
/*
1116-
* Give the user a hint that this is a message propagated from a parallel
1117-
* worker. Otherwise, it can sometimes be confusing to understand what
1118-
* actually happened.
1119-
*/
1120-
staticvoid
1121-
ParallelErrorContext(void*arg)
1122-
{
1123-
if (force_parallel_mode!=FORCE_PARALLEL_REGRESS)
1124-
errcontext("parallel worker");
1125-
}
1126-
11271127
/*
11281128
* Update shared memory with the ending location of the last WAL record we
11291129
* wrote, if it's greater than the value already stored there.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp