archive-standby-checks.patch
text/x-diff
Filename: archive-standby-checks.patch
Type: text/x-diff
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlogarchive.c | 9 | 2 |
diff --git a/src/backend/access/transam/xlogarchive.c b/src/backend/access/transam/xlogarchive.c
index 4a039b1190..a0e53119ef 100644
--- a/src/backend/access/transam/xlogarchive.c
+++ b/src/backend/access/transam/xlogarchive.c
@@ -620,9 +620,16 @@ XLogArchiveCheckDone(const char *xlog)
{
char archiveStatusPath[MAXPGPATH];
struct stat stat_buf;
+ bool inRecovery = RecoveryInProgress();
- /* Always deletable if archiving is off */
- if (!XLogArchivingActive())
+ /*
+ * The file is always deletable if archive_mode is "off". On standbys
+ * archiving is disabled if archive_mode is "on", and enabled with
+ * "always". On a primary, archiving is enabled if archive_mode is
+ * "on" or "always".
+ */
+ if (!((XLogArchivingActive() && !inRecovery) ||
+ (XLogArchivingAlways() && inRecovery)))
return true;
/* First check for .done --- this means archiver is done with it */