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

Commite9f69ab

Browse files
committed
Fix handling of signals in threads
1 parent9e416ef commite9f69ab

File tree

11 files changed

+251
-233
lines changed

11 files changed

+251
-233
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static session_local MemoryContext DatabaseListCxt = NULL;
303303
staticsession_localWorkerInfoMyWorkerInfo=NULL;
304304

305305
/* PID of launcher, valid only in worker while shutting down */
306-
session_localintAutovacuumLauncherPid=0;
306+
session_localpthread_tAutovacuumLauncherPid=0;
307307

308308
#ifdefEXEC_BACKEND
309309
staticsession_localpthread_tavlauncher_forkexec(void);
@@ -397,7 +397,7 @@ static void* autovacuum_main_proc(void* arg)
397397
* Main entry point for autovacuum launcher process, to be called from the
398398
* postmaster.
399399
*/
400-
int
400+
pthread_t
401401
StartAutoVacLauncher(void)
402402
{
403403
pthread_tAutoVacPID;
@@ -407,7 +407,7 @@ StartAutoVacLauncher(void)
407407
(errmsg("could not fork autovacuum launcher process: %m")));
408408
return0;
409409
}else {
410-
return(int)AutoVacPID;
410+
returnAutoVacPID;
411411
}
412412
}
413413

@@ -1421,76 +1421,28 @@ avl_sigterm_handler(SIGNAL_ARGS)
14211421
* AUTOVACUUM WORKER CODE
14221422
********************************************************************/
14231423

1424-
#ifdefEXEC_BACKEND
1425-
/*
1426-
* forkexec routines for the autovacuum worker.
1427-
*
1428-
* Format up the arglist, then fork and exec.
1429-
*/
1430-
staticpthread_t
1431-
avworker_forkexec(void)
1432-
{
1433-
char*av[10];
1434-
intac=0;
1435-
1436-
av[ac++]="postgres";
1437-
av[ac++]="--forkavworker";
1438-
av[ac++]=NULL;/* filled in by postmaster_forkexec */
1439-
av[ac]=NULL;
1440-
1441-
Assert(ac<lengthof(av));
1442-
1443-
returnpostmaster_forkexec(ac,av);
1444-
}
1445-
1446-
/*
1447-
* We need this set from the outside, before InitProcess is called
1448-
*/
1449-
void
1450-
AutovacuumWorkerIAm(void)
1424+
staticvoid*autovac_worker_main_proc(void*arg)
14511425
{
1452-
am_autovacuum_worker= true;
1426+
AutoVacWorkerMain(0,NULL);
1427+
returnNULL;
14531428
}
1454-
#endif
14551429

14561430
/*
14571431
* Main entry point for autovacuum worker process.
14581432
*
14591433
* This code is heavily based on pgarch.c, q.v.
14601434
*/
1461-
int
1435+
pthread_t
14621436
StartAutoVacWorker(void)
14631437
{
1464-
pthread_tworker_pid;
1438+
pthread_tworker_pid=0;
14651439

1466-
#ifdefEXEC_BACKEND
1467-
switch ((worker_pid=avworker_forkexec()))
1468-
#else
1469-
switch ((worker_pid=fork_process()))
1470-
#endif
1440+
if (!create_thread(&worker_pid,autovac_worker_main_proc,NULL))
14711441
{
1472-
case-1:
1473-
ereport(LOG,
1474-
(errmsg("could not fork autovacuum worker process: %m")));
1475-
return0;
1476-
1477-
#ifndefEXEC_BACKEND
1478-
case0:
1479-
/* in postmaster child ... */
1480-
InitPostmasterChild();
1481-
1482-
/* Close the postmaster's sockets */
1483-
ClosePostmasterPorts(false);
1484-
1485-
AutoVacWorkerMain(0,NULL);
1486-
break;
1487-
#endif
1488-
default:
1489-
return (int)worker_pid;
1442+
ereport(LOG,
1443+
(errmsg("could not fork autovacuum worker process: %m")));
14901444
}
1491-
1492-
/* shouldn't get here */
1493-
return0;
1445+
returnworker_pid;
14941446
}
14951447

14961448
/*

‎src/backend/postmaster/checkpointer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ CheckpointerMain(void)
465465
"checkpoints are occurring too frequently (%d seconds apart)",
466466
elapsed_secs,
467467
elapsed_secs),
468-
errhint("Consider increasing the configuration parameter \"max_wal_size\".")));
468+
errhint("Consider increasing the configuration parameter \"max_wal_size\" (%d Mb).",max_wal_size_mb)));
469469

470470
/*
471471
* Initialize checkpointer-private variables used during

‎src/backend/postmaster/pgstat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ static void* pgstat_main_proc(void* arg)
728728
*
729729
*Note: if fail, we will be called again from the postmaster main loop.
730730
*/
731-
int
731+
pthread_t
732732
pgstat_start(void)
733733
{
734734
time_tcurtime;
@@ -764,7 +764,7 @@ pgstat_start(void)
764764
}
765765
else
766766
{
767-
return(int)pgStatPid;
767+
returnpgStatPid;
768768
}
769769
}
770770

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp