Re: Function to track shmem reinit time

Поиск
Список
Период
Сортировка
От Grigory Smolkin
Тема Re: Function to track shmem reinit time
Дата
Msg-id d2a8af68-8e7c-22ef-59a8-238c05bd2a37@postgrespro.ru
обсуждение исходный текст
Ответ на Function to track shmem reinit time  (Anastasia Lubennikova <a.lubennikova@postgrespro.ru>)
Ответы Re: Function to track shmem reinit time
Список pgsql-hackers

It can be used to accurately calculate server uptime, since you can`t rely on pg_postmaster_start_time() in this.

On 02/28/2018 03:11 PM, Anastasia Lubennikova wrote:

Attached patch introduces a new function pg_shmem_init_time(),
which returns the time shared memory was last (re)initialized.
It is created for use by monitoring tools to track backend crashes.

Currently, if the 'restart_after_crash' option is on, postgres will just restart.
And the only way to know that it happened is to regularly parse logfile
or monitor it, catching restart messages. This approach is really inconvenient for
users, who have gigabytes of logs.

This new function can be periodiacally called by a monitoring agent, and,
if shmem_init_time doesn't match pg_postmaster_start_time,
we know that server crashed-restarted, and also know the exact time, when.

Also, working on this patch, I noticed a bit of dead code
and some discordant comments in postmaster.c.
I see no reason to leave it as is.
So there is a small remove_dead_shmem_reinit_code_v0.patch.

-- 
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

-- 
Grigory Smolkin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Contention preventing locking
Следующее
От: Grigory Smolkin
Дата:
Сообщение: Re: Reopen logfile on SIGHUP