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@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support