Tom Lane wrote:
> Alvaro Herrera <[EMAIL PROTECTED]> writes:
> > Ah -- like this?
>
> +1, but there are two kinds of temp files in that module, and only
> one of them is relevant here. Call it something like
> have_xact_temporary_files to make things clearer.
Ok, so that's what I called it.
Simon wrote:
> if test should include
> || isProcExit
>
> so you don't skip non-transactional temp files at proc exit when there
> weren't any created in the last transaction.
Yep, I noticed that too. Thanks.
Should I backpatch this to 8.3?
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Index: src/backend/storage/file/fd.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/storage/file/fd.c,v
retrieving revision 1.143
diff -c -p -r1.143 fd.c
*** src/backend/storage/file/fd.c 1 Jan 2008 19:45:51 -0000 1.143
--- src/backend/storage/file/fd.c 17 Sep 2008 22:58:32 -0000
*************** static int max_safe_fds = 32; /* default
*** 121,126 ****
--- 121,132 ----
#define FD_TEMPORARY (1 << 0) /* T = delete when closed */
#define FD_XACT_TEMPORARY (1 << 1) /* T = delete at eoXact */
+ /*
+ * Flag to tell whether it's worth scanning VfdCache looking for temp files to
+ * close
+ */
+ static bool have_xact_temporary_files = false;
+
typedef struct vfd
{
signed short fd; /* current FD, or VFD_CLOSED if none */
*************** OpenTemporaryFile(bool interXact)
*** 889,894 ****
--- 895,903 ----
{
VfdCache[file].fdstate |= FD_XACT_TEMPORARY;
VfdCache[file].create_subid = GetCurrentSubTransactionId();
+
+ /* ensure cleanup happens at eoxact */
+ have_xact_temporary_files = true;
}
return file;
*************** AtEOSubXact_Files(bool isCommit, SubTran
*** 1603,1609 ****
{
Index i;
! if (SizeVfdCache > 0)
{
Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */
for (i = 1; i < SizeVfdCache; i++)
--- 1612,1618 ----
{
Index i;
! if (have_xact_temporary_files)
{
Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */
for (i = 1; i < SizeVfdCache; i++)
*************** CleanupTempFiles(bool isProcExit)
*** 1679,1685 ****
{
Index i;
! if (SizeVfdCache > 0)
{
Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */
for (i = 1; i < SizeVfdCache; i++)
--- 1688,1698 ----
{
Index i;
! /*
! * Careful here: at proc_exit we need extra cleanup, not just
! * xact_temporary files.
! */
! if (isProcExit || have_xact_temporary_files)
{
Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */
for (i = 1; i < SizeVfdCache; i++)
*************** CleanupTempFiles(bool isProcExit)
*** 1697,1702 ****
--- 1710,1717 ----
FileClose(i);
}
}
+
+ have_xact_temporary_files = false;
}
while (numAllocatedDescs > 0)
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers