| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: pg_receivewal, pg_basebackup: Fix temporary file cleanup on erro |
| Date: | 2026-11-25 07:23:40 |
| Message-ID: | E1xW7Lw-00000000EfZ-0HrM@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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 <lic(at)highgo(dot)com>
Reviewed-by: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/9C37FACF-2D67-450D-864A-344F81229860@gmail.com
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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-11-25 08:07:09 | pgsql: Fix -Wcast-qual warning in guc_funcs.c |
| Previous Message | Fujii Masao | 2026-11-25 07:16:43 | pgsql: Fix lost wakeups in logical WAL senders |