pgsql: Close un-owned SMgrRelations at transaction end.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Close un-owned SMgrRelations at transaction end.
Date: 2012-10-17 16:39:08
Message-ID: E1TOWeC-0007fb-Eu@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Close un-owned SMgrRelations at transaction end.

If an SMgrRelation is not "owned" by a relcache entry, don't allow it to
live past transaction end. This design allows the same SMgrRelation to be
used for blind writes of multiple blocks during a transaction, but ensures
that we don't hold onto such an SMgrRelation indefinitely. Because an
SMgrRelation typically corresponds to open file descriptors at the fd.c
level, leaving it open when there's no corresponding relcache entry can
mean that we prevent the kernel from reclaiming deleted disk space.
(While CacheInvalidateSmgr messages usually fix that, there are cases
where they're not issued, such as DROP DATABASE. We might want to add
some more sinval messaging for that, but I'd be inclined to keep this
type of logic anyway, since allowing VFDs to accumulate indefinitely
for blind-written relations doesn't seem like a good idea.)

This code replaces a previous attempt towards the same goal that proved
to be unreliable. Back-patch to 9.1 where the previous patch was added.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/473320e6c87cc7ffc704b2823c685b3dd13c0342

Modified Files
--------------
src/backend/access/transam/xact.c | 5 +-
src/backend/postmaster/bgwriter.c | 1 +
src/backend/postmaster/walwriter.c | 1 +
src/backend/storage/smgr/smgr.c | 80 +++++++++++++++++++++++++++++++++++-
src/include/storage/smgr.h | 7 +++
5 files changed, 91 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2012-10-18 11:23:04 Re: pgsql: Provide some static-assertion functionality on all compilers.
Previous Message Alvaro Herrera 2012-10-17 14:41:00 pgsql: Embedded list interface