pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jon Nelson <jnelson+pgsql@jamponi.net>
Cc: pgsql-bugs@postgresql.org
Subject: Re: temporary tables, and lots of 0 byte files
Date: Mon, 22 Nov 2010 23:11:59 -0500
Message-ID: <25742.1290485519@sss.pgh.pa.us> (raw)
In-Reply-To: <AANLkTimX+zy-r2nMon2tYV--uEg=CdOkh0rBrpTLssXy@mail.gmail.com>
References: <AANLkTimX+zy-r2nMon2tYV--uEg=CdOkh0rBrpTLssXy@mail.gmail.com>

Jon Nelson <jnelson+pgsql@jamponi.net> writes:
> Here is the problem: When I started benchmarking this application, I
> noticed it (postgresql) started chewing up inodes on the logical
> volume which houses /var/lib/pgsql.  It chewed up a few thousand
> inodes, and then a few thousand more, and then there were no more.

> I investigated /var/lib/pgsql/data/ and found within the database's
> directory many thousands of 0-byte files.  I stopped the application
> expecting at the end of a /session/ that the inodes would be unlinked,
> but there was no change. lsof told me nobody had them open. However, a
> start/stop of postgresql removed (at least most of) the 0-byte files.
> After some trial and error, I straced the right process (the bgwriter
> process) and found that, upon signal to leave, it would write some
> checkpoint-y stuff and then proceed about unlinking most or all of the
> 0-byte files.

This is not a bug; it's normal behavior when dropping a table.  The
table file is truncated to zero bytes at commit, but it's not unlinked
until the next checkpoint.  I surmise that you may have a very long
checkpoint cycle time selected.

> What can be done to remove all of the files associated with dropped
> (temporary) tables _when_ the they are dropped?

Nothing other than forcing a checkpoint.  There are
race-condition-related reasons for doing it like this, which I don't
have at the top of my brain, but you can find them in the archives
if you care enough.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <25742.1290485519@sss.pgh.pa.us>
Permalink:  ../25742.1290485519@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25742.1290485519@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jnelson+pgsql@jamponi.net
  Subject: Re: temporary tables, and lots of 0 byte files
  In-Reply-To: <25742.1290485519@sss.pgh.pa.us>
  References: <AANLkTimX+zy-r2nMon2tYV--uEg=CdOkh0rBrpTLssXy@mail.gmail.com> <25742.1290485519@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox