Remove temporary files after backend crash
authorTomas Vondra <tomas.vondra@postgresql.org>
Thu, 18 Mar 2021 15:05:03 +0000 (16:05 +0100)
committerTomas Vondra <tomas.vondra@postgresql.org>
Thu, 18 Mar 2021 16:38:28 +0000 (17:38 +0100)
commitcd91de0d17952b5763466cfa663e98318f26d357
treed0e543e40dc62b32ccf4cbb34cbe3bb77f2ba78d
parentda18d829c28197efb04805a43f129f62650e50c8
Remove temporary files after backend crash

After a crash of a backend using temporary files, the files used to be
left behind, on the basis that it might be useful for debugging. But we
don't have any reports of anyone actually doing that, and it means the
disk usage may grow over time due to repeated backend failures (possibly
even hitting ENOSPC). So this behavior is a bit unfortunate, and fixing
it required either manual cleanup (deleting files, which is error-prone)
or restart of the instance (i.e. service disruption).

This implements automatic cleanup of temporary files, controled by a new
GUC remove_temp_files_after_crash. By default the files are removed, but
it can be disabled to restore the old behavior if needed.

Author: Euler Taveira
Reviewed-by: Tomas Vondra, Michael Paquier, Anastasia Lubennikova, Thomas Munro
Discussion: https://postgr.es/m/CAH503wDKdYzyq7U-QJqGn%3DGm6XmoK%2B6_6xTJ-Yn5WSvoHLY1Ww%40mail.gmail.com
doc/src/sgml/config.sgml
src/backend/postmaster/postmaster.c
src/backend/storage/file/fd.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample
src/include/postmaster/postmaster.h
src/test/recovery/t/022_crash_temp_files.pl [new file with mode: 0644]