Is Backgroundworker.bgw_restart_time is defined in seconds?

From: constzl <const_sunny(at)126(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Is Backgroundworker.bgw_restart_time is defined in seconds?
Date: 2021-08-26 07:38:12
Message-ID: 4baeccb.80f0.17b81651c54.Coremail.const_sunny@126.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

typedef struct BackgroundWorker
{
char bgw_name[BGW_MAXLEN];
char bgw_type[BGW_MAXLEN];
int bgw_flags;
BgWorkerStartTime bgw_start_time;
int bgw_restart_time; /* in seconds, or BGW_NEVER_RESTART */
char bgw_library_name[BGW_MAXLEN];
char bgw_function_name[BGW_MAXLEN];
Datum bgw_main_arg;
char bgw_extra[BGW_EXTRALEN];
pid_t bgw_notify_pid; /* SIGUSR1 this backend on start/stop */
} BackgroundWorker;

static bool
SanityCheckBackgroundWorker(BackgroundWorker *worker, int elevel)
{
... ...

if ((worker->bgw_restart_time < 0 &&
worker->bgw_restart_time != BGW_NEVER_RESTART) ||
(worker->bgw_restart_time > USECS_PER_DAY / 1000))

> The Backgroundworker.bgw_restart_time is defined in seconds,
> so should it be "USECS_PER_DAY / 1000,000" here instead of "USECS_PER_DAY / 1000"?
> Or am I getting it wrong?

{
ereport(elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("background worker \"%s\": invalid restart interval",
worker->bgw_name)));
return false;
}
... ...

}

Regards!

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2021-08-26 08:09:36 Re: Is Backgroundworker.bgw_restart_time is defined in seconds?
Previous Message Masahiko Sawada 2021-08-26 07:26:41 Re: pg_basebackup behavior on non-existent slot