have SLRU truncation use callbacks

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема have SLRU truncation use callbacks
Дата
Msg-id 1317311162-sup-6022@alvh.no-ip.org
обсуждение исходный текст
Ответы Re: have SLRU truncation use callbacks
Список pgsql-hackers
Hi,

Currently, the mechanism that SLRU uses to truncate directory entries is
hardcoded in SlruScanDirectory.  It receives a cutoff page number and a
boolean flag; segments found in the SLRU directory that are below the
cutoff are deleted -- iff the flag is true.

This is fine for most current uses, with one exception, but it is a bit
too ad-hoc.  The exception is the new NOTIFY code (async.c); on
postmaster (re)start, that module wants to simply zap all files found in
the directory.  So it forcibly sets a different "pagePrecedes" routine,
then calls the truncation procedure with a made-up cutoff page.

Also, clog.c has a check that it scans the directory to figure out if
any segments would be removed, were we to do the thing for real.  (This
is so that it can skip WAL flush in case none would).

(Now, this code is also getting in the way of some changes I want to do
on multixact truncation for the keylocks patch; hence the motivation.
But I think these changes stand on their own, merely on code clarity
grounds).

So what I propose is that we turn SlruScanDirectory into a mere
directory walker, and it invokes a callback on each file.  We provide
three callbacks: one that simply removes everything (for NOTIFY); one
that removes everything before a given cutoff page; and a simple one
that reports "is there any removable file given this cutoff", for clog.c
uses.

Patch is attached.

Opinions?

--
Álvaro Herrera <alvherre@alvh.no-ip.org>

Вложения

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

Предыдущее
От: Linas Virbalas
Дата:
Сообщение: Re: Hot Backup with rsync fails at pg_clog if under load
Следующее
От: Marios Vodas
Дата:
Сообщение: Temporary tables and in-memory use