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

Commit4a4a37e

Browse files
committed
Fix start of auxiliary processes
1 parent4d9a498 commit4a4a37e

File tree

17 files changed

+259
-191
lines changed

17 files changed

+259
-191
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ LaunchParallelWorkers(ParallelContext *pcxt)
470470

471471
/* Configure a worker. */
472472
memset(&worker,0,sizeof(worker));
473-
snprintf(worker.bgw_name,BGW_MAXLEN,"parallel worker for PID %d",
473+
snprintf(worker.bgw_name,BGW_MAXLEN,"parallel worker for PID %ld",
474474
MyProcPid);
475475
snprintf(worker.bgw_type,BGW_MAXLEN,"parallel worker");
476476
worker.bgw_flags=

‎src/backend/bootstrap/bootstrap.c

Lines changed: 79 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static session_local IndexList *ILHead = NULL;
195195
void
196196
AuxiliaryProcessMain(intargc,char*argv[])
197197
{
198-
char*progname=argv[0];
198+
char*progname=(char*)"aux";
199199
intflag;
200200
char*userDoption=NULL;
201201

@@ -215,104 +215,107 @@ AuxiliaryProcessMain(int argc, char *argv[])
215215
if (!IsUnderPostmaster)
216216
InitializeGUCOptions();
217217

218-
/* Ignore the initial --boot argument, if present */
219-
if (argc>1&&strcmp(argv[1],"--boot")==0)
218+
if (argv!=NULL)
220219
{
221-
argv++;
222-
argc--;
223-
}
220+
progname=argv[0];
221+
/* Ignore the initial --boot argument, if present */
222+
if (argc>1&&strcmp(argv[1],"--boot")==0)
223+
{
224+
argv++;
225+
argc--;
226+
}
224227

225-
/* If no -x argument, we are a CheckerProcess */
226-
MyAuxProcType=CheckerProcess;
228+
/* If no -x argument, we are a CheckerProcess */
229+
MyAuxProcType=CheckerProcess;
227230

228-
while ((flag=getopt(argc,argv,"B:c:d:D:Fkr:x:X:-:"))!=-1)
229-
{
230-
switch (flag)
231+
while ((flag=getopt(argc,argv,"B:c:d:D:Fkr:x:X:-:"))!=-1)
231232
{
232-
case'B':
233+
switch (flag)
234+
{
235+
case'B':
233236
SetConfigOption("shared_buffers",optarg,PGC_POSTMASTER,PGC_S_ARGV);
234237
break;
235-
case'D':
238+
case'D':
236239
userDoption=pstrdup(optarg);
237240
break;
238-
case'd':
239-
{
240-
/* Turn on debugging for the bootstrap process. */
241-
char*debugstr;
242-
243-
debugstr=psprintf("debug%s",optarg);
244-
SetConfigOption("log_min_messages",debugstr,
245-
PGC_POSTMASTER,PGC_S_ARGV);
246-
SetConfigOption("client_min_messages",debugstr,
247-
PGC_POSTMASTER,PGC_S_ARGV);
248-
pfree(debugstr);
249-
}
250-
break;
251-
case'F':
241+
case'd':
242+
{
243+
/* Turn on debugging for the bootstrap process. */
244+
char*debugstr;
245+
246+
debugstr=psprintf("debug%s",optarg);
247+
SetConfigOption("log_min_messages",debugstr,
248+
PGC_POSTMASTER,PGC_S_ARGV);
249+
SetConfigOption("client_min_messages",debugstr,
250+
PGC_POSTMASTER,PGC_S_ARGV);
251+
pfree(debugstr);
252+
}
253+
break;
254+
case'F':
252255
SetConfigOption("fsync","false",PGC_POSTMASTER,PGC_S_ARGV);
253256
break;
254-
case'k':
257+
case'k':
255258
bootstrap_data_checksum_version=PG_DATA_CHECKSUM_VERSION;
256259
break;
257-
case'r':
260+
case'r':
258261
strlcpy(OutputFileName,optarg,MAXPGPATH);
259262
break;
260-
case'x':
263+
case'x':
261264
MyAuxProcType=atoi(optarg);
262265
break;
263-
case'X':
264-
{
265-
intWalSegSz=strtoul(optarg,NULL,0);
266-
267-
if (!IsValidWalSegSize(WalSegSz))
268-
ereport(ERROR,
269-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
270-
errmsg("-X requires a power of 2 value between 1MB and 1GB")));
271-
SetConfigOption("wal_segment_size",optarg,PGC_INTERNAL,
272-
PGC_S_OVERRIDE);
273-
}
274-
break;
275-
case'c':
276-
case'-':
277-
{
278-
char*name,
279-
*value;
280-
281-
ParseLongOption(optarg,&name,&value);
282-
if (!value)
283-
{
284-
if (flag=='-')
285-
ereport(ERROR,
286-
(errcode(ERRCODE_SYNTAX_ERROR),
287-
errmsg("--%s requires a value",
288-
optarg)));
289-
else
290-
ereport(ERROR,
291-
(errcode(ERRCODE_SYNTAX_ERROR),
292-
errmsg("-c %s requires a value",
293-
optarg)));
294-
}
295-
296-
SetConfigOption(name,value,PGC_POSTMASTER,PGC_S_ARGV);
297-
free(name);
298-
if (value)
299-
free(value);
300-
break;
301-
}
302-
default:
266+
case'X':
267+
{
268+
intWalSegSz=strtoul(optarg,NULL,0);
269+
270+
if (!IsValidWalSegSize(WalSegSz))
271+
ereport(ERROR,
272+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
273+
errmsg("-X requires a power of 2 value between 1MB and 1GB")));
274+
SetConfigOption("wal_segment_size",optarg,PGC_INTERNAL,
275+
PGC_S_OVERRIDE);
276+
}
277+
break;
278+
case'c':
279+
case'-':
280+
{
281+
char*name,
282+
*value;
283+
284+
ParseLongOption(optarg,&name,&value);
285+
if (!value)
286+
{
287+
if (flag=='-')
288+
ereport(ERROR,
289+
(errcode(ERRCODE_SYNTAX_ERROR),
290+
errmsg("--%s requires a value",
291+
optarg)));
292+
else
293+
ereport(ERROR,
294+
(errcode(ERRCODE_SYNTAX_ERROR),
295+
errmsg("-c %s requires a value",
296+
optarg)));
297+
}
298+
299+
SetConfigOption(name,value,PGC_POSTMASTER,PGC_S_ARGV);
300+
free(name);
301+
if (value)
302+
free(value);
303+
break;
304+
}
305+
default:
303306
write_stderr("Try \"%s --help\" for more information.\n",
304307
progname);
305308
proc_exit(1);
306309
break;
310+
}
307311
}
308-
}
309312

310-
if (argc!=optind)
311-
{
312-
write_stderr("%s: invalid command-line arguments\n",progname);
313-
proc_exit(1);
313+
if (argc!=optind)
314+
{
315+
write_stderr("%s: invalid command-line arguments\n",progname);
316+
proc_exit(1);
317+
}
314318
}
315-
316319
/*
317320
* Identify myself via ps
318321
*/

‎src/backend/postmaster/autovacuum.c

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,13 @@ AutovacuumLauncherIAm(void)
387387
}
388388
#endif
389389

390+
staticvoid*autovacuum_proc_main(void*arg)
391+
{
392+
initialize_thread(arg,NULL);
393+
AutoVacLauncherMain(0,NULL);
394+
returnNULL;
395+
}
396+
390397
/*
391398
* Main entry point for autovacuum launcher process, to be called from the
392399
* postmaster.
@@ -396,34 +403,13 @@ StartAutoVacLauncher(void)
396403
{
397404
pthread_tAutoVacPID;
398405

399-
#ifdefEXEC_BACKEND
400-
switch ((AutoVacPID=avlauncher_forkexec()))
401-
#else
402-
switch ((AutoVacPID=fork_process()))
403-
#endif
404-
{
405-
case-1:
406-
ereport(LOG,
407-
(errmsg("could not fork autovacuum launcher process: %m")));
408-
return0;
409-
410-
#ifndefEXEC_BACKEND
411-
case0:
412-
/* in postmaster child ... */
413-
InitPostmasterChild();
414-
415-
/* Close the postmaster's sockets */
416-
ClosePostmasterPorts(false);
417-
418-
AutoVacLauncherMain(0,NULL);
419-
break;
420-
#endif
421-
default:
422-
return (int)AutoVacPID;
406+
if (!create_thread(&AutoVacPID,autovacuum_proc_main,NULL)) {
407+
ereport(LOG,
408+
(errmsg("could not fork autovacuum launcher process: %m")));
409+
return0;
410+
}else {
411+
return (int)AutoVacPID;
423412
}
424-
425-
/* shouldn't get here */
426-
return0;
427413
}
428414

429415
/*

‎src/backend/postmaster/checkpointer.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,6 @@ RequestCheckpoint(int flags)
970970
intold_failed,
971971
old_started;
972972

973-
return;
974-
975973
/*
976974
* If in a standalone backend, just do it ourselves.
977975
*/

‎src/backend/postmaster/pgstat.c

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,12 @@ pgstat_forkexec(void)
712712
}
713713
#endif/* EXEC_BACKEND */
714714

715+
staticvoid*pgstat_proc_main(void*arg)
716+
{
717+
initialize_thread(arg,NULL);
718+
PgstatCollectorMain(0,NULL);
719+
returnNULL;
720+
}
715721

716722
/*
717723
* pgstat_start() -
@@ -751,39 +757,16 @@ pgstat_start(void)
751757
/*
752758
* Okay, fork off the collector.
753759
*/
754-
#ifdefEXEC_BACKEND
755-
switch ((pgStatPid=pgstat_forkexec()))
756-
#else
757-
switch ((pgStatPid=fork_process()))
758-
#endif
760+
if (!create_thread(&pgStatPid,pgstat_proc_main,NULL))
759761
{
760-
case-1:
761-
ereport(LOG,
762-
(errmsg("could not fork statistics collector: %m")));
763-
return0;
764-
765-
#ifndefEXEC_BACKEND
766-
case0:
767-
/* in postmaster child ... */
768-
InitPostmasterChild();
769-
770-
/* Close the postmaster's sockets */
771-
ClosePostmasterPorts(false);
772-
773-
/* Drop our connection to postmaster's shared memory, as well */
774-
dsm_detach_all();
775-
PGSharedMemoryDetach();
776-
777-
PgstatCollectorMain(0,NULL);
778-
break;
779-
#endif
780-
781-
default:
782-
return (int)pgStatPid;
762+
ereport(LOG,
763+
(errmsg("could not fork statistics collector: %m")));
764+
return0;
765+
}
766+
else
767+
{
768+
return (int)pgStatPid;
783769
}
784-
785-
/* shouldn't get here */
786-
return0;
787770
}
788771

789772
void

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp