]> granicus.if.org Git - postgresql/commit
Use "transient" files for blind writes, take 2
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 10 Jun 2011 17:43:02 +0000 (13:43 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 10 Jun 2011 17:43:02 +0000 (13:43 -0400)
commitfba105b1099f4f5fa7283bb17cba6fed2baa8d0c
tree5f430842e2309bb35735edb47f5e4ef6451107fd
parent3d114b63b253605eb60055c910aa2e55c98d5ed2
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.
src/backend/storage/buffer/bufmgr.c
src/backend/storage/file/fd.c
src/backend/storage/smgr/md.c
src/backend/storage/smgr/smgr.c
src/include/storage/fd.h
src/include/storage/smgr.h