]> granicus.if.org Git - postgresql/commit
Use "transient" files for blind writes
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 9 Jun 2011 17:41:12 +0000 (13:41 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 9 Jun 2011 20:25:49 +0000 (16:25 -0400)
commit54d9e8c6c19cbefa8fb42ed3442a0a5327590ed3
tree2d7a0f2175c005fc616b29eba5a727533ccf862a
parent74b1d29dd186c4ea51ba1eff06aebd1faeb5dfcd
Use "transient" files for blind writes

"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.)
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