The last WAL segment of the old timeline is not archived for a while after archive recovery

Started by Fujii Masaoover 16 years ago3 messages
#1Fujii Masao
masao.fujii@gmail.com
1 attachment(s)

Hi,

In archive recovery, the last applied WAL segment may not have
.ready file in spite of not having been archived yet. Then, this
segment is not archived until a future checkpoint creates .ready
file. It's a little dangerous that there is the WAL segment which
is not archived for a while.

Attached patch fixes this problem. Is this worth committing?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachments:

archive_last_wal_0422.patchapplication/octet-stream; name=archive_last_wal_0422.patchDownload
Index: src/backend/access/transam/xlog.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xlog.c,v
retrieving revision 1.335
diff -c -r1.335 xlog.c
*** src/backend/access/transam/xlog.c	7 Apr 2009 00:31:26 -0000	1.335
--- src/backend/access/transam/xlog.c	22 Apr 2009 08:47:45 -0000
***************
*** 4850,4859 ****
--- 4850,4871 ----
  		 * If we are establishing a new timeline, we have to copy data from
  		 * the last WAL segment of the old timeline to create a starting WAL
  		 * segment for the new timeline.
+ 		 *
+ 		 * Notify the archiver that the last WAL segment of the old timeline
+ 		 * is ready to copy to archival storage. Otherwise, it is not archived
+ 		 * for a while.
  		 */
  		if (endTLI != ThisTimeLineID)
+ 		{
  			XLogFileCopy(endLogId, endLogSeg,
  						 endTLI, endLogId, endLogSeg);
+ 
+ 			if (XLogArchivingActive())
+ 			{
+ 				XLogFileName(xlogpath, endTLI, endLogId, endLogSeg);
+ 				XLogArchiveNotify(xlogpath);
+ 			}
+ 		}
  	}
  
  	/*
#2Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Fujii Masao (#1)
Re: The last WAL segment of the old timeline is not archived for a while after archive recovery

Fujii Masao wrote:

In archive recovery, the last applied WAL segment may not have
.ready file in spite of not having been archived yet. Then, this
segment is not archived until a future checkpoint creates .ready
file. It's a little dangerous that there is the WAL segment which
is not archived for a while.

Attached patch fixes this problem. Is this worth committing?

Yeah, I think it is. Applied.

BTW, I notice that we have the same problem with WAL files that have
been manually copied into pg_xlog, in the unlikely corner case that the
"backup redo point", ControlData->checkpointCopy, points to the
first-ever WAL file. That's because we then skip the
RemoveOldXlogFiles() step in the startup checkpoint, which normally
creates the .ready files for all but the last WAL file. I don't think
that happens in practice, and if it does, the files will still be
archived at the next checkpoint, so I think we can leave it as it is.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#3Fujii Masao
masao.fujii@gmail.com
In reply to: Heikki Linnakangas (#2)
Re: The last WAL segment of the old timeline is not archived for a while after archive recovery

Hi,

On Thu, Apr 23, 2009 at 4:51 AM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

Fujii Masao wrote:

In archive recovery, the last applied WAL segment may not have
.ready file in spite of not having been archived yet. Then, this
segment is not archived until a future checkpoint creates .ready
file. It's a little dangerous that there is the WAL segment which
is not archived for a while.

Attached patch fixes this problem. Is this worth committing?

Yeah, I think it is. Applied.

Thanks a lot!

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center