pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-hackers@postgresql.org
Subject: mdtruncate leaking fd.c handles?
Date: Thu, 8 Sep 2016 15:07:48 -0700
Message-ID: <20160908220748.oqh37ukwqqncbl3n@alap3.anarazel.de> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Hi,

Am I missing something or is md.c:mdtruncate() leaking open files?
The relevant piece of code is:

		if (priorblocks > nblocks)
		{
			/*
			 * This segment is no longer active (and has already been unlinked
			 * from the mdfd_chain). We truncate the file, but do not delete
			 * it, for reasons explained in the header comments.
			 */
			if (FileTruncate(v->mdfd_vfd, 0) < 0)
				ereport(ERROR,
						(errcode_for_file_access(),
						 errmsg("could not truncate file \"%s\": %m",
								FilePathName(v->mdfd_vfd))));

			if (!SmgrIsTemp(reln))
				register_dirty_segment(reln, forknum, v);
			v = v->mdfd_chain;
			Assert(ov != reln->md_fd[forknum]); /* we never drop the 1st
												 * segment */
			pfree(ov);
		}

note that we're freeing the chain entry, which contains the mdfd_vfd,
without previously calling FileClose().

This only really matters for VACUUM truncate and ON COMMIT TRUNCATE temp
table truncation afaics.  But it seems like we should fix it everywhere
nonetheless.

Greetings,

Andres Freund


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (4+ messages)  latest in thread

Message-ID: <20160908220748.oqh37ukwqqncbl3n@alap3.anarazel.de>
Permalink:  ../20160908220748.oqh37ukwqqncbl3n@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20160908220748.oqh37ukwqqncbl3n@alap3.anarazel.de

 · 

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-hackers@postgresql.org
  Cc: andres@anarazel.de
  Subject: Re: mdtruncate leaking fd.c handles?
  In-Reply-To: <20160908220748.oqh37ukwqqncbl3n@alap3.anarazel.de>
  References: <20160908220748.oqh37ukwqqncbl3n@alap3.anarazel.de>

* 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