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 <alvhe...@alvh.no-ip.org>
slru-truncate-callbacks.patch
Description: Binary data
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers