summaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorMichael Paquier2022-04-28 04:08:16 +0000
committerMichael Paquier2022-04-28 04:08:16 +0000
commit55b56865115eccd6449e79d6f06fe49d6ba3b792 (patch)
tree06e87b08b6c6a27e472448c7edd1407b8f7e707d /src/backend/access
parente84f82ab5cff2811745ae8e2ac163a4b8b733394 (diff)
Revert recent changes with durable_rename_excl()
This reverts commits 2c902bb and ccfbd92. Per buildfarm members kestrel, rorqual and calliphoridae, the assertions checking that a TLI history file should not exist when created by a WAL receiver have been failing, and switching to durable_rename() over durable_rename_excl() would cause the newest TLI history file to overwrite the existing one. We need to think harder about such cases, so revert the new logic for now. Note that all the failures have been reported in the test 025_stuck_on_old_timeline. Discussion: https://postgr.es/m/511362.1651116498@sss.pgh.pa.us
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/transam/timeline.c18
-rw-r--r--src/backend/access/transam/xlog.c10
2 files changed, 18 insertions, 10 deletions
diff --git a/src/backend/access/transam/timeline.c b/src/backend/access/transam/timeline.c
index c9344e5e8b4..be21968293c 100644
--- a/src/backend/access/transam/timeline.c
+++ b/src/backend/access/transam/timeline.c
@@ -439,11 +439,14 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
/*
* Now move the completed history file into place with its final name.
- * The target file should not exist.
*/
TLHistoryFilePath(path, newTLI);
- Assert(access(path, F_OK) != 0 && errno == ENOENT);
- durable_rename(tmppath, path, ERROR);
+
+ /*
+ * Perform the rename using link if available, paranoidly trying to avoid
+ * overwriting an existing file (there shouldn't be one).
+ */
+ durable_rename_excl(tmppath, path, ERROR);
/* The history file can be archived immediately. */
if (XLogArchivingActive())
@@ -514,11 +517,14 @@ writeTimeLineHistoryFile(TimeLineID tli, char *content, int size)
/*
* Now move the completed history file into place with its final name.
- * The target file should not exist.
*/
TLHistoryFilePath(path, tli);
- Assert(access(path, F_OK) != 0 && errno == ENOENT);
- durable_rename(tmppath, path, ERROR);
+
+ /*
+ * Perform the rename using link if available, paranoidly trying to avoid
+ * overwriting an existing file (there shouldn't be one).
+ */
+ durable_rename_excl(tmppath, path, ERROR);
}
/*
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 45c84e3959c..61cda56c6ff 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -3323,12 +3323,14 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
}
}
- /* The target file should not exist */
- Assert(access(path, F_OK) != 0 && errno == ENOENT);
- if (durable_rename(tmppath, path, LOG) != 0)
+ /*
+ * Perform the rename using link if available, paranoidly trying to avoid
+ * overwriting an existing file (there shouldn't be one).
+ */
+ if (durable_rename_excl(tmppath, path, LOG) != 0)
{
LWLockRelease(ControlFileLock);
- /* durable_rename already emitted log message */
+ /* durable_rename_excl already emitted log message */
return false;
}