diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index a31fbbff78..09f49ac1a3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6805,24 +6805,39 @@ CreateCheckPoint(int flags) if (PriorRedoPtr != InvalidXLogRecPtr) UpdateCheckPointDistanceEstimate(RedoRecPtr - PriorRedoPtr); - /* - * Delete old log files, those no longer needed for last checkpoint to - * prevent the disk holding the xlog from growing full. - */ - XLByteToSeg(RedoRecPtr, _logSegNo, wal_segment_size); - KeepLogSeg(recptr, &_logSegNo); - if (InvalidateObsoleteReplicationSlots(_logSegNo)) { + char lastoff[MAXFNAMELEN]; + /* - * Some slots have been invalidated; recalculate the old-segment - * horizon, starting again from RedoRecPtr. + * Delete old log files, those no longer needed for last checkpoint to + * prevent the disk holding the xlog from growing full. */ XLByteToSeg(RedoRecPtr, _logSegNo, wal_segment_size); + elog(LOG, "attempting to remove WAL segments older than log file %s before first KeepLogSeg, slotMinLSN: %X/%X", + lastoff, XLogGetReplicationSlotMinimumLSN()); KeepLogSeg(recptr, &_logSegNo); + + XLogFileName(lastoff, 0, _logSegNo, wal_segment_size); + + elog(LOG, "attempting to remove WAL segments older than log file %s according to first KeepLogSeg, slotMinLSN: %X/%X", + lastoff, XLogGetReplicationSlotMinimumLSN()); + if (InvalidateObsoleteReplicationSlots(_logSegNo)) + { + /* + * Some slots have been invalidated; recalculate the old-segment + * horizon, starting again from RedoRecPtr. + */ + XLByteToSeg(RedoRecPtr, _logSegNo, wal_segment_size); + KeepLogSeg(recptr, &_logSegNo); + } + _logSegNo--; + XLogFileName(lastoff, 0, _logSegNo, wal_segment_size); + + elog(LOG, "attempting to remove WAL segments older than log file %s after invalidating required slots, slotMinLSN: %X/%X", + lastoff, lastoff, XLogGetReplicationSlotMinimumLSN()); + RemoveOldXlogFiles(_logSegNo, RedoRecPtr, recptr, + checkPoint.ThisTimeLineID); } - _logSegNo--; - RemoveOldXlogFiles(_logSegNo, RedoRecPtr, recptr, - checkPoint.ThisTimeLineID); /* * Make more log segments if needed. (Do this after recycling old log