From acb1dc39b4242700e6729d575bbf55fea9dfad17 Mon Sep 17 00:00:00 2001
From: vrhappy <songlong88@126.com>
Date: Sat, 25 May 2024 14:17:01 +0800
Subject: [PATCH v2] Fix error-report missing in SimpleLruWriteAll

---
 src/backend/access/transam/slru.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 77b05cc0a..c663f78cc 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -1365,6 +1365,15 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
 			slru_errno = errno;
 			pageno = fdata.segno[i] * SLRU_PAGES_PER_SEGMENT;
 			ok = false;
+			// record all the error failing to close file
+			char path[MAXPGPATH];
+			SlruFileName(ctl, path, fdata.segno[i]);
+			errno = slru_errno;
+			ereport(LOG,
+					(errcode_for_file_access(),
+					 errmsg("could not access status of transaction %u", InvalidTransactionId),
+					 errdetail("Could not close file \"%s\": %m.",
+							   path)));
 		}
 	}
 	if (!ok)
-- 
2.43.0.windows.1

