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

Commit6737111

Browse files
committed
When restoring GUCs in parallel workers, show an error context.
Otherwise it can be hard to see where an error is coming from, whenthe parallel worker sets all the GUCs that it received from theleader. Bug #15726. Back-patch to 9.5, where RestoreGUCState()appeared.Reported-by: Tiago AnastacioReviewed-by: Daniel Gustafsson, Tom LaneDiscussion:https://postgr.es/m/15726-6d67e4fa14f027b3%40postgresql.org
1 parent6f1e336 commit6737111

File tree

1 file changed

+29
-0
lines changed
  • src/backend/utils/misc

1 file changed

+29
-0
lines changed

‎src/backend/utils/misc/guc.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9594,6 +9594,21 @@ read_gucstate_binary(char **srcptr, char *srcend, void *dest, Size size)
95949594
*srcptr+=size;
95959595
}
95969596

9597+
/*
9598+
* Callback used to add a context message when reporting errors that occur
9599+
* while trying to restore GUCs in parallel workers.
9600+
*/
9601+
staticvoid
9602+
guc_restore_error_context_callback(void*arg)
9603+
{
9604+
char**error_context_name_and_value= (char**)arg;
9605+
9606+
if (error_context_name_and_value)
9607+
errcontext("while setting parameter \"%s\" to \"%s\"",
9608+
error_context_name_and_value[0],
9609+
error_context_name_and_value[1]);
9610+
}
9611+
95979612
/*
95989613
* RestoreGUCState:
95999614
* Reads the GUC state at the specified address and updates the GUCs with the
@@ -9612,6 +9627,7 @@ RestoreGUCState(void *gucstate)
96129627
char*srcend;
96139628
Sizelen;
96149629
inti;
9630+
ErrorContextCallbackerror_context_callback;
96159631

96169632
/* See comment at can_skip_gucvar(). */
96179633
for (i=0;i<num_guc_variables;i++)
@@ -9624,9 +9640,16 @@ RestoreGUCState(void *gucstate)
96249640
srcptr+=sizeof(len);
96259641
srcend=srcptr+len;
96269642

9643+
/* If the GUC value check fails, we want errors to show useful context. */
9644+
error_context_callback.callback=guc_restore_error_context_callback;
9645+
error_context_callback.previous=error_context_stack;
9646+
error_context_callback.arg=NULL;
9647+
error_context_stack=&error_context_callback;
9648+
96279649
while (srcptr<srcend)
96289650
{
96299651
intresult;
9652+
char*error_context_name_and_value[2];
96309653

96319654
varname=read_gucstate(&srcptr,srcend);
96329655
varvalue=read_gucstate(&srcptr,srcend);
@@ -9641,6 +9664,9 @@ RestoreGUCState(void *gucstate)
96419664
read_gucstate_binary(&srcptr,srcend,
96429665
&varscontext,sizeof(varscontext));
96439666

9667+
error_context_name_and_value[0]=varname;
9668+
error_context_name_and_value[1]=varvalue;
9669+
error_context_callback.arg=&error_context_name_and_value[0];
96449670
result=set_config_option(varname,varvalue,varscontext,varsource,
96459671
GUC_ACTION_SET, true,ERROR, true);
96469672
if (result <=0)
@@ -9649,7 +9675,10 @@ RestoreGUCState(void *gucstate)
96499675
errmsg("parameter \"%s\" could not be set",varname)));
96509676
if (varsourcefile[0])
96519677
set_config_sourcefile(varname,varsourcefile,varsourceline);
9678+
error_context_callback.arg=NULL;
96529679
}
9680+
9681+
error_context_stack=error_context_callback.previous;
96539682
}
96549683

96559684
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp