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

---
 src/backend/access/transam/slru.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 77b05cc0a..d0f0d68b3 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -1307,7 +1307,6 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
 	SlruWriteAllData fdata;
 	int64		pageno = 0;
 	int			prevbank = SlotGetBankNumber(0);
-	bool		ok;
 
 	/* update the stats counter of flushes */
 	pgstat_count_slru_flush(shared->slru_stats_idx);
@@ -1356,7 +1355,6 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
 	/*
 	 * Now close any files that were open
 	 */
-	ok = true;
 	for (int i = 0; i < fdata.num_files; i++)
 	{
 		if (CloseTransientFile(fdata.fd[i]) != 0)
@@ -1364,11 +1362,9 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
 			slru_errcause = SLRU_CLOSE_FAILED;
 			slru_errno = errno;
 			pageno = fdata.segno[i] * SLRU_PAGES_PER_SEGMENT;
-			ok = false;
+			SlruReportIOError(ctl, pageno, InvalidTransactionId);
 		}
 	}
-	if (!ok)
-		SlruReportIOError(ctl, pageno, InvalidTransactionId);
 
 	/* Ensure that directory entries for new files are on disk. */
 	if (ctl->sync_handler != SYNC_HANDLER_NONE)
-- 
2.43.0.windows.1

