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

Commit3c8c55d

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 parent6bda2af commit3c8c55d

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
@@ -10209,6 +10209,21 @@ read_gucstate_binary(char **srcptr, char *srcend, void *dest, Size size)
1020910209
*srcptr+=size;
1021010210
}
1021110211

10212+
/*
10213+
* Callback used to add a context message when reporting errors that occur
10214+
* while trying to restore GUCs in parallel workers.
10215+
*/
10216+
staticvoid
10217+
guc_restore_error_context_callback(void*arg)
10218+
{
10219+
char**error_context_name_and_value= (char**)arg;
10220+
10221+
if (error_context_name_and_value)
10222+
errcontext("while setting parameter \"%s\" to \"%s\"",
10223+
error_context_name_and_value[0],
10224+
error_context_name_and_value[1]);
10225+
}
10226+
1021210227
/*
1021310228
* RestoreGUCState:
1021410229
* Reads the GUC state at the specified address and updates the GUCs with the
@@ -10227,6 +10242,7 @@ RestoreGUCState(void *gucstate)
1022710242
char*srcend;
1022810243
Sizelen;
1022910244
inti;
10245+
ErrorContextCallbackerror_context_callback;
1023010246

1023110247
/* See comment at can_skip_gucvar(). */
1023210248
for (i=0;i<num_guc_variables;i++)
@@ -10239,9 +10255,16 @@ RestoreGUCState(void *gucstate)
1023910255
srcptr+=sizeof(len);
1024010256
srcend=srcptr+len;
1024110257

10258+
/* If the GUC value check fails, we want errors to show useful context. */
10259+
error_context_callback.callback=guc_restore_error_context_callback;
10260+
error_context_callback.previous=error_context_stack;
10261+
error_context_callback.arg=NULL;
10262+
error_context_stack=&error_context_callback;
10263+
1024210264
while (srcptr<srcend)
1024310265
{
1024410266
intresult;
10267+
char*error_context_name_and_value[2];
1024510268

1024610269
varname=read_gucstate(&srcptr,srcend);
1024710270
varvalue=read_gucstate(&srcptr,srcend);
@@ -10256,6 +10279,9 @@ RestoreGUCState(void *gucstate)
1025610279
read_gucstate_binary(&srcptr,srcend,
1025710280
&varscontext,sizeof(varscontext));
1025810281

10282+
error_context_name_and_value[0]=varname;
10283+
error_context_name_and_value[1]=varvalue;
10284+
error_context_callback.arg=&error_context_name_and_value[0];
1025910285
result=set_config_option(varname,varvalue,varscontext,varsource,
1026010286
GUC_ACTION_SET, true,ERROR, true);
1026110287
if (result <=0)
@@ -10264,7 +10290,10 @@ RestoreGUCState(void *gucstate)
1026410290
errmsg("parameter \"%s\" could not be set",varname)));
1026510291
if (varsourcefile[0])
1026610292
set_config_sourcefile(varname,varsourcefile,varsourceline);
10293+
error_context_callback.arg=NULL;
1026710294
}
10295+
10296+
error_context_stack=error_context_callback.previous;
1026810297
}
1026910298

1027010299
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp