pg_receivewal, pg_basebackup: Fix temporary file cleanup on errors pg_receivewal and the WAL streaming process of pg_basebackup could leave temporary files behind when closing them failed, even though their removal had been requested. For example, a temporary timeline history file could remain after a write failure, unnecessarily occupying disk space.
This happened because dir_close() attempted to unlink a file requested with CLOSE_UNLINK only if the preceding operations succeeded. Failures while finalizing compression, writing the final compressed data, or closing the file could therefore skip the unlink operation. Fix this by moving the unlink operation into the common cleanup path, so that it is attempted even after an earlier failure. Backpatch to all supported versions. Author: Chao Li <[email protected]> Reviewed-by: Xuneng Zhou <[email protected]> Reviewed-by: Fujii Masao <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 15 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5f73181c06f49ba33e1abceceb0eeaab19fb9e13 Modified Files -------------- src/bin/pg_basebackup/walmethods.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
