Hi, This derives from a previous patch [1] that fixed a resource leak issue in dir_close() for pg_receivewal. While reviewing the patch, I found a path where, if an LZ4 compression operation fails, the current code goes directly to error handling, bypassing the CLOSE_UNLINK branch, which may cause a temporary file leak. I raised the issue as a review comment, then Fujii-san considered it a separate issue that would be better fixed by a new patch.
This patch moves the CLOSE_UNLINK handling into the common cleanup path, so a preceding operation failure (such as LZ4 compressing or file closing) won't prevent unlinking the temporary file. If unlinking also fails, we preserve the earlier error rather than reporting the unlink failure. See the attached patch for the detailed changes. [1] https://postgr.es/m/CAHGQGwHfCrEogr6=wr0nckqevaj9a3hbqqrjt9ijryo7ejf...@mail.gmail.com Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/
v1-0001-Ensure-CLOSE_UNLINK-removes-files-even-after-earl.patch
Description: Binary data
