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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix error handling in temp-file deletion with log_temp_files act
Дата
Msg-id E1PFegR-0000g7-6h@gemulon.postgresql.org
обсуждение исходный текст
Список 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
------
REL9_0_STABLE

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

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


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix error handling in temp-file deletion with log_temp_files act
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix error handling in temp-file deletion with log_temp_files act