Re: pgstat: delayed write of stats file

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: pgstat: delayed write of stats file
Дата
Msg-id 6BCB9D8A16AC4241919521715F4D8BCEA3524F@algol.sollentuna.se
обсуждение исходный текст
Ответ на pgstat: delayed write of stats file  ("Magnus Hagander" <mha@sollentuna.net>)
Список pgsql-patches
> > Per some earlier discussion, here is an attempt at implementing a
> > "delayed write" of the pgstats file, to decrease the write
> activity on
> > that file.
> >
> > It changes so the file is only written once every 5 minutes
> > (changeable of course, I just picked something) instead of
> once every half second.
> > It's still written when the stats collector shuts down,
> just as before.
> > And it is now also written on backend request. A backend requests a
> > rewrite by simply sending a special stats message. It
> operates on the
> > assumption that the backends aren't actually going to read the
> > statistics file very often, compared to how frequent it's
> written today.
>
> If somebody tries to read something from the pgstat file, is
> the backend going to request a rewrite and wait until it is complete?

Not sure which part you mean, so I'll answer both ;)

Scenario: One backend reads the file. Second backend requests rewrite.
The write is initiated and later renamed()d into place. As the first
backend still has the file open it'll just continue to read off that
version of the file.

The requesting backend will wait for the file to change, and then read
the new version. So it'll wait for a complete rewrite of the file (with
a timeout of course, in which case we'll read the old file and report a
warning).

//Magnus

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: pgstat: delayed write of stats file
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pgstat: delayed write of stats file