pgsql: Fix error handling in temp-file deletion with log_temp_files act - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix error handling in temp-file deletion with log_temp_files act
Date
Msg-id E1PFegR-0000g9-85@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix error handling in temp-file deletion with log_temp_files active.

The original coding in FileClose() reset the file-is-temp flag before
unlinking the file, so that if control came back through due to an error,
it wouldn't try to unlink the file twice.  This was correct when written,
but when the log_temp_files feature was added, the logging action was put
in between those two steps.  An error occurring during the logging action
--- such as a query cancel --- would result in the unlink not getting done
at all, as in recent report from Michael Glaesemann.

To fix this, make sure that we do both the stat and the unlink before doing
anything that could conceivably CHECK_FOR_INTERRUPTS.  There is a judgment
call here, which is which log message to emit first: if you can see only
one, which should it be?  I chose to log unlink failure at the risk of
losing the log_temp_files log message --- after all, if the unlink does
fail, the temp file is still there for you to see.

Back-patch to all versions that have log_temp_files.  The code was OK
before that.

Branch
------
REL8_3_STABLE

Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=99a87edadee6d1eb6f6b8e00aded239b7157720b

Modified Files
--------------
src/backend/storage/file/fd.c |   39 +++++++++++++++++++++++++++++++++------
1 files changed, 33 insertions(+), 6 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix error handling in temp-file deletion with log_temp_files act
Next
From: hinoue@pgfoundry.org (User Hinoue)
Date:
Subject: psqlodbc - psqlodbc: Improved a mylog output.