pgsql: Use "transient" files for blind writes, take 2 - Mailing list pgsql-committers

From Alvaro Herrera
Subject pgsql: Use "transient" files for blind writes, take 2
Date
Msg-id E1QV6EM-0004nc-Tf@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Use "transient" files for blind writes, take 2

"Blind writes" are a mechanism to push buffers down to disk when
evicting them; since they may belong to different databases than the one
a backend is connected to, the backend does not necessarily have a
relation to link them to, and thus no way to blow them away.  We were
keeping those files open indefinitely, which would cause a problem if
the underlying table was deleted, because the operating system would not
be able to reclaim the disk space used by those files.

To fix, have bufmgr mark such files as transient to smgr; the lower
layer is allowed to close the file descriptor when the current
transaction ends.  We must be careful to have any other access of the
file to remove the transient markings, to prevent unnecessary expensive
system calls when evicting buffers belonging to our own database (which
files we're likely to require again soon.)

This commit fixes a bug in the previous one, which neglected to cleanly
handle the LRU ring that fd.c uses to manage open files, and caused an
unacceptable failure just before beta2 and was thus reverted.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/fba105b1099f4f5fa7283bb17cba6fed2baa8d0c

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c |   10 +++-
src/backend/storage/file/fd.c       |   91 +++++++++++++++++++++++++----------
src/backend/storage/smgr/md.c       |    9 ++++
src/backend/storage/smgr/smgr.c     |   17 +++++++
src/include/storage/fd.h            |    1 +
src/include/storage/smgr.h          |    2 +
6 files changed, 102 insertions(+), 28 deletions(-)


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: Use a constant sprintf format to silence compiler warning
Next
From: Alvaro Herrera
Date:
Subject: pgsql: Add comment about pg_ctl stop