[Pgpool-hackers] check replication lag (streaming replication)

Anton Yuzhaninov citrin at citrin.ru
Wed May 4 15:56:54 UTC 2011


I have two questions/suggestions about replication lag check for straming 
replication in pgpool-II.

1. In text_to_lsn() there is formula

lsn = xlogid * 16 * 1024 * 1024 * 255 + xrecoff;

16 * 1024 * 1024 * 255 = 4278190080 = 0xff000000

where this magic numbers come from?

I think multiplier should be
0xffffffff - XLogSegSize.

In PostgreeSQL source this constant used in
src/include/access/xlog_internal.h

#define XLogSegsPerFile (((uint32) 0xffffffff) / XLogSegSize)

But in comment noted, that one segment at the end of each log file is wasted

Each xlogid corresponds to (XLogSegsPerFile - 1) * XLogSegSize = 0xffffffff - 
XLogSegSize bytes

2. On slave better to use
SELECT pg_last_xlog_replay_location()
instead
SELECT pg_last_xlog_receive_location()

if we want to know if slave will return stale data on SELECTs to user's databases.

-- 
  Anton Yuzhaninov


More information about the Pgpool-hackers mailing list