From 9cc69017ed6028cfaf21c4709f4527c7d206ea2f Mon Sep 17 00:00:00 2001 From: Takashi Menjo Date: Wed, 25 Mar 2020 11:19:05 +0900 Subject: [PATCH v3 08/10] Create a new WAL segment just before mapping --- src/backend/access/transam/xlog.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 777a9e921c..5a6304176b 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -3430,9 +3430,20 @@ XLogFileMap(XLogSegNo segno, bool *is_pmem) fd = BasicOpenFile(path, O_RDWR | PG_BINARY); if (fd < 0) - ereport(PANIC, - (errcode_for_file_access(), - errmsg("could not open file \"%s\": %m", path))); + { + bool use_existent = true; + + /* + * Create a new logfile segment if not exists. This is an exceptional + * creation because it should be done at the end of checkpoint. So we + * log this as warning. + */ + elog(WARNING, + "creating logfile segment just before mapping; path \"%s\"", + path); + + fd = XLogFileInit(segno, &use_existent, true); + } if (fstat(fd, &stat_buf) != 0) ereport(PANIC, -- 2.25.1