Re: Postmaster holding unlinked files for pg_largeobject table

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Kevin Grittner <kevin(dot)grittner(at)wicourts(dot)gov>, alexk <alexk(at)commandprompt(dot)com>, Alexander Shulgin <ash(at)commandprompt(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Postmaster holding unlinked files for pg_largeobject table
Date: 2011-06-09 20:55:41
Message-ID: 1307652727-sup-4445@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Excerpts from Alvaro Herrera's message of jue jun 09 16:34:13 -0400 2011:

> I have pushed it now.

... and it caused a failure on the buildfarm, so I panicked and reverted
it. I think the patch below fixes it. Let me know if you think I
should push the whole thing again.

*** a/src/backend/storage/file/fd.c
--- b/src/backend/storage/file/fd.c
***************
*** 1045,1070 **** FileSetTransient(File file)
}

/*
- * Close a file at the kernel level, but keep the VFD open
- */
- static void
- FileKernelClose(File file)
- {
- Vfd *vfdP;
-
- Assert(FileIsValid(file));
-
- vfdP = &VfdCache[file];
-
- if (!FileIsNotOpen(file))
- {
- if (close(vfdP->fd))
- elog(ERROR, "could not close file \"%s\": %m", vfdP->fileName);
- vfdP->fd = VFD_CLOSED;
- }
- }
-
- /*
* close a file when done with it
*/
void
--- 1045,1050 ----
***************
*** 1892,1903 **** CleanupTempFiles(bool isProcExit)
else if (fdstate & FD_XACT_TRANSIENT)
{
/*
! * Close the kernel file descriptor, but also remove the
! * flag from the VFD. This is to ensure that if the VFD is
! * reused in the future for non-transient access, we don't
! * close it inappropriately then.
*/
! FileKernelClose(i);
VfdCache[i].fdstate &= ~FD_XACT_TRANSIENT;
}
}
--- 1872,1884 ----
else if (fdstate & FD_XACT_TRANSIENT)
{
/*
! * Close the FD, and remove the entry from the LRU ring,
! * but also remove the flag from the VFD. This is to
! * ensure that if the VFD is reused in the future for
! * non-transient access, we don't close it inappropriately
! * then.
*/
! LruDelete(i);
VfdCache[i].fdstate &= ~FD_XACT_TRANSIENT;
}
}
--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-06-09 21:10:10 Re: Postmaster holding unlinked files for pg_largeobject table
Previous Message Tom Lane 2011-06-09 20:41:03 Re: Postmaster holding unlinked files for pg_largeobject table

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-06-09 21:05:11 Re: pgsql: Use "transient" files for blind writes
Previous Message Bernd Helmle 2011-06-09 20:43:09 Re: tuning autovacuum