BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: harukat(at)sraoss(dot)co(dot)jp
Subject: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
Date: 2018-09-26 03:26:50
Message-ID: 15402-a453c90ed4cf88b2@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15402
Logged by: TAKATSUKA Haruka
Email address: harukat(at)sraoss(dot)co(dot)jp
PostgreSQL version: 11beta4
Operating system: Linux (CentOS 6)
Description:

Hello PostgreSQL hackers,

A hot standby server with “archive_mode = on” keeps initial WAL segment
files
that copied by pg_basebackup. It shows the following status.
000000010000000000000042 will be kept forever in this case.

$ ls data_primary/pg_wal/
000000010000000000000042.00000028.backup 00000001000000000000004D
000000010000000000000048 00000001000000000000004E
000000010000000000000049 00000001000000000000004F
00000001000000000000004A 000000010000000000000050
00000001000000000000004B 000000010000000000000051
00000001000000000000004C archive_status
$ ls data_standby/pg_wal/
000000010000000000000042 00000001000000000000004B
00000001000000000000004F
000000010000000000000048 00000001000000000000004C archive_status
000000010000000000000049 00000001000000000000004D
00000001000000000000004A 00000001000000000000004E
$ ls data_standby/pg_wal/archive_status/
000000010000000000000042.ready 00000001000000000000004A.done
000000010000000000000048.done 00000001000000000000004B.done
000000010000000000000049.done 00000001000000000000004C.done

Though I understand renaming the .ready to .done manually can clean it,
I would like to fix the server code like the following patch.
I'd appreciate if you would consider that.

- - - - -
diff --git a/src/backend/access/transam/xlog.c
b/src/backend/access/transam/xlog.c
index 5abaeb0..191ba60 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -3963,7 +3963,9 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr
RedoRecPtr, XLogRecPtr endptr)
*/
if (strcmp(xlde->d_name + 8, lastoff + 8) <= 0)
{
- if (XLogArchiveCheckDone(xlde->d_name))
+ if (XLogArchiveCheckDone(xlde->d_name) ||
+ (XLogArchiveMode != ARCHIVE_MODE_ALWAYS &&
+ XLogCtl->SharedRecoveryInProgress))
{
/* Update the last removed location in shared memory first */
UpdateLastRemovedPtr(xlde->d_name);
- - - - - -

Thanks,

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2018-09-26 03:52:05 Re: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
Previous Message steven schienschang 2018-09-26 00:18:49 pgadmin is missing items on the list