diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 9b64578..f54dd3b 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -3106,7 +3106,12 @@ RemoveOldXlogFiles(uint32 log, uint32 seg, XLogRecPtr endptr)
 					ereport(DEBUG2,
 							(errmsg("removing transaction log file \"%s\"",
 									xlde->d_name)));
-					unlink(path);
+
+					if (unlink(path) != 0)
+						ereport(ERROR,
+								(errcode_for_file_access(),
+								 errmsg("could not remove old transaction log file \"%s\": %m",
+										path)));
 					CheckpointStats.ckpt_segs_removed++;
 				}
 
