have SLRU truncation use callbacks

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: have SLRU truncation use callbacks
Date: 2011-09-29 15:58:41
Message-ID: 1317311162-sup-6022@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)alvh(dot)no-ip(dot)org>

Attachment Content-Type Size
slru-truncate-callbacks.patch application/octet-stream 12.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marios Vodas 2011-09-29 16:47:53 Temporary tables and in-memory use
Previous Message Linas Virbalas 2011-09-29 15:44:59 Re: Hot Backup with rsync fails at pg_clog if under load