PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID15402
PG Version11beta4
OSLinux (CentOS 6)
Opened2018-09-26 03:26:50+00
Reported byTAKATSUKA Haruka
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      15402
Logged by:          TAKATSUKA Haruka
Email address:      (redacted)
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,

Messages

DateAuthorSubject
2018-09-26 03:26:50+00=?utf-8?q?PG_Bug_reporting_form?=BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
2018-09-26 03:52:05+00Michael PaquierRe: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
2018-09-26 04:36:40+00TAKATSUKA HarukaRe: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
2018-09-26 05:12:36+00TAKATSUKA HarukaRe: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
2018-09-27 04:44:30+00Michael PaquierRe: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
2018-09-28 03:02:08+00Michael PaquierRe: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
2018-09-28 03:20:03+00TAKATSUKA HarukaRe: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
2018-09-28 03:32:43+00Michael PaquierRe: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments
2018-09-28 03:57:37+00TAKATSUKA HarukaRe: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments