pgsql: Fix stats collector to recover nicely when system clock goes bac

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix stats collector to recover nicely when system clock goes bac
Дата
Msg-id E1SgMlc-0000CD-55@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix stats collector to recover nicely when system clock goes backwards.

Formerly, if the system clock went backwards, the stats collector would
fail to update the stats file any more until the clock reading again
exceeds whatever timestamp was last written into the stats file.  Such
glitches in the clock's behavior are not terribly unlikely on machines
not using NTP.  Such a scenario has been observed to cause regression test
failures in the buildfarm, and it could have bad effects on the behavior
of autovacuum, so it seems prudent to install some defenses.

We could directly detect the clock going backwards by adding
GetCurrentTimestamp calls in the stats collector's main loop, but that
would hurt performance on platforms where GetCurrentTimestamp is expensive.
To minimize the performance hit in normal cases, adopt a more complicated
scheme wherein backends check for clock skew when reading the stats file,
and if they see it, signal the stats collector by sending an extra stats
inquiry message.  The stats collector does an extra GetCurrentTimestamp
only when it receives an inquiry with an apparently out-of-order
timestamp.

To avoid unnecessary GetCurrentTimestamp calls, expand the inquiry messages
to carry the backend's current clock reading as well as its stats cutoff
time.  The latter, being intentionally slightly in-the-past, would trigger
more clock rechecks than we need if it were used for this purpose.

We might want to backpatch this change at some point, but let's let it
shake out in the buildfarm for awhile first.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9e18eacbdff2ae2abd5ff38eee725e6399e39b41

Modified Files
--------------
src/backend/postmaster/pgstat.c |  145 ++++++++++++++++++++++++++++++--------
src/include/pgstat.h            |    3 +-
2 files changed, 116 insertions(+), 32 deletions(-)


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

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: pgsql: Add missing subtitle for compressed archive logs
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Make documentation of --help and --version options more consiste