mirror of
https://gitee.com/he3db/he3pg.git
synced 2024-12-03 12:47:34 +08:00
singal problem
Code Source From: Self Code Description: [Optional] Jira: #[Optional] 市场项目编号(名称):[Optional]
This commit is contained in:
parent
2311fe482a
commit
e6aa362acb
@ -869,7 +869,65 @@ void SignalStartFlushWork(void) {
|
||||
usleep(200000);
|
||||
}
|
||||
|
||||
void StartALLPageFlushWorker(void) {
|
||||
for(int i = 0;i<PARALLEL_NUM;i++) {
|
||||
/*
|
||||
* Compute the cancel key that will be assigned to this session. We
|
||||
* probably don't need cancel keys for autovac workers, but we'd
|
||||
* better have something random in the field to prevent unfriendly
|
||||
* people from sending cancels to them.
|
||||
*/
|
||||
Backend *bn;
|
||||
/*
|
||||
* Compute the cancel key that will be assigned to this session. We
|
||||
* probably don't need cancel keys for autovac workers, but we'd
|
||||
* better have something random in the field to prevent unfriendly
|
||||
* people from sending cancels to them.
|
||||
*/
|
||||
if (!RandomCancelKey(&MyCancelKey))
|
||||
{
|
||||
ereport(LOG,
|
||||
(errcode(ERRCODE_INTERNAL_ERROR),
|
||||
errmsg("could not generate random cancel key")));
|
||||
return;
|
||||
}
|
||||
|
||||
bn = (Backend *) malloc(sizeof(Backend));
|
||||
if (bn)
|
||||
{
|
||||
bn->cancel_key = MyCancelKey;
|
||||
|
||||
/* parallel workers are not dead_end and need a child slot */
|
||||
bn->dead_end = false;
|
||||
bn->child_slot = MyPMChildSlot = AssignPostmasterChildSlot();
|
||||
bn->bgworker_notify = false;
|
||||
|
||||
bn->pid = StartPageFlushWorker();
|
||||
if (bn->pid > 0)
|
||||
{
|
||||
bn->bkend_type = BACKEND_TYPE_FLUSHPAGE;
|
||||
dlist_push_head(&BackendList, &bn->elem);
|
||||
#ifdef EXEC_BACKEND
|
||||
ShmemBackendArrayAdd(bn);
|
||||
#endif
|
||||
/* all OK */
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* fork failed, fall through to report -- actual error message was
|
||||
* logged by StartAutoVacWorker
|
||||
*/
|
||||
(void) ReleasePostmasterChildSlot(bn->child_slot);
|
||||
free(bn);
|
||||
}
|
||||
else
|
||||
ereport(LOG,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of memory")));
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Main entry point for autovacuum worker process.
|
||||
*
|
||||
@ -901,7 +959,7 @@ StartPageFlushWorker(void)
|
||||
|
||||
CreateAuxProcessResourceOwner();
|
||||
|
||||
MyPMChildSlot = AssignPostmasterChildSlot();
|
||||
//MyPMChildSlot = AssignPostmasterChildSlot();
|
||||
|
||||
IsParallelFlushWorker = true;
|
||||
|
||||
|
@ -147,7 +147,8 @@
|
||||
#define BACKEND_TYPE_AUTOVAC 0x0002 /* autovacuum worker process */
|
||||
#define BACKEND_TYPE_WALSND 0x0004 /* walsender process */
|
||||
#define BACKEND_TYPE_BGWORKER 0x0008 /* bgworker process */
|
||||
#define BACKEND_TYPE_ALL 0x000F /* OR of all the above */
|
||||
#define BACKEND_TYPE_FLUSHPAGE 0x0010 /* parallel flush pid*/
|
||||
#define BACKEND_TYPE_ALL 0x001F /* OR of all the above */
|
||||
|
||||
/*
|
||||
* List of active backends (or child processes anyway; we don't actually
|
||||
@ -5306,10 +5307,9 @@ sigusr1_handler(SIGNAL_ARGS)
|
||||
/* start Flush Page */
|
||||
if (!PageParallelPush && CheckPostmasterSignal(PMSIGNAL_PARALLEL_FLUSH_WORKER)) {
|
||||
PageParallelPush = true;
|
||||
for(int i = 0;i<PARALLEL_NUM;i++) {
|
||||
StartPageFlushWorker();
|
||||
}
|
||||
StartALLPageFlushWorker();
|
||||
}
|
||||
|
||||
if (CheckPostmasterSignal(PMSIGNAL_START_WALRECEIVER))
|
||||
{
|
||||
/* Startup Process wants us to start the walreceiver process. */
|
||||
@ -5721,7 +5721,7 @@ int
|
||||
MaxLivePostmasterChildren(void)
|
||||
{
|
||||
return 2 * (MaxConnections + autovacuum_max_workers + 1 +
|
||||
max_wal_senders + max_worker_processes);
|
||||
max_wal_senders + max_parallel_flush_process + max_worker_processes);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -12003,7 +12003,7 @@ static bool
|
||||
check_maxconnections(int *newval, void **extra, GucSource source)
|
||||
{
|
||||
if (*newval + autovacuum_max_workers + 1 +
|
||||
max_worker_processes + max_wal_senders > MAX_BACKENDS)
|
||||
max_worker_processes + max_parallel_flush_process + max_wal_senders > MAX_BACKENDS)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -12012,7 +12012,7 @@ static bool
|
||||
check_autovacuum_max_workers(int *newval, void **extra, GucSource source)
|
||||
{
|
||||
if (MaxConnections + *newval + 1 +
|
||||
max_worker_processes + max_wal_senders > MAX_BACKENDS)
|
||||
max_worker_processes + max_parallel_flush_process + max_wal_senders > MAX_BACKENDS)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -12021,7 +12021,7 @@ static bool
|
||||
check_max_wal_senders(int *newval, void **extra, GucSource source)
|
||||
{
|
||||
if (MaxConnections + autovacuum_max_workers + 1 +
|
||||
max_worker_processes + *newval > MAX_BACKENDS)
|
||||
max_worker_processes + max_parallel_flush_process + *newval > MAX_BACKENDS)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -12052,8 +12052,8 @@ check_autovacuum_work_mem(int *newval, void **extra, GucSource source)
|
||||
static bool
|
||||
check_max_worker_processes(int *newval, void **extra, GucSource source)
|
||||
{
|
||||
if (MaxConnections + autovacuum_max_workers + 1 +
|
||||
*newval + max_wal_senders > MAX_BACKENDS)
|
||||
if (MaxConnections + autovacuum_max_workers + 1 +
|
||||
*newval + max_parallel_flush_process + max_wal_senders > MAX_BACKENDS)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user