replay_location indicates incorrect location

Started by Fujii Masaoalmost 14 years ago2 messages
#1Fujii Masao
masao.fujii@gmail.com
1 attachment(s)

Hi,

When I looked at pg_stat_replication just after starting the standby before
executing any write transactions on the master, I found that replay_location
indicated incorrect location different from sent/write/flush_location. Then,
if I ran write transaction on the master, replay_location indicated the same
location as the others.

The cause of this problem is that Xlogctl->recoveryLastRecPtr which points
to replay_location is initialized with wrong variable ReadRecPtr. Instead, it
should be initialized with EndRecPtr. Attached patch does that. This needs
to be backported to 9.0.

Regards,

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

Attachments:

incorrect_replay_location_v1.patchtext/x-diff; charset=US-ASCII; name=incorrect_replay_location_v1.patchDownload
*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
***************
*** 6407,6413 **** StartupXLOG(void)
  		 */
  		SpinLockAcquire(&xlogctl->info_lck);
  		xlogctl->replayEndRecPtr = ReadRecPtr;
! 		xlogctl->recoveryLastRecPtr = ReadRecPtr;
  		xlogctl->recoveryLastXTime = 0;
  		xlogctl->currentChunkStartTime = 0;
  		xlogctl->recoveryPause = false;
--- 6407,6413 ----
  		 */
  		SpinLockAcquire(&xlogctl->info_lck);
  		xlogctl->replayEndRecPtr = ReadRecPtr;
! 		xlogctl->recoveryLastRecPtr = EndRecPtr;
  		xlogctl->recoveryLastXTime = 0;
  		xlogctl->currentChunkStartTime = 0;
  		xlogctl->recoveryPause = false;
#2Simon Riggs
simon@2ndQuadrant.com
In reply to: Fujii Masao (#1)
Re: replay_location indicates incorrect location

On Fri, Jan 13, 2012 at 10:04 AM, Fujii Masao <masao.fujii@gmail.com> wrote:

When I looked at pg_stat_replication just after starting the standby before
executing any write transactions on the master, I found that replay_location
indicated incorrect location different from sent/write/flush_location. Then,
if I ran write transaction on the master, replay_location indicated the same
location as the others.

The cause of this problem is that Xlogctl->recoveryLastRecPtr which points
to replay_location is initialized with wrong variable ReadRecPtr. Instead, it
should be initialized with EndRecPtr. Attached patch does that. This needs
to be backported to 9.0.

Agreed. Will commit.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services