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

Tatsuo Ishii ishii at sraoss.co.jp
Thu May 5 02:35:38 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.

Thanks for the suggestion. I fixed the calculation of LSN and change
pg_last_xlog_receive_location() to pg_last_xlog_replay_location().

See included patches for more details.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pool_worker_child.patch
Type: text/x-patch
Size: 1490 bytes
Desc: not available
URL: <http://pgfoundry.org/pipermail/pgpool-hackers/attachments/20110505/6919c391/attachment.bin>


More information about the Pgpool-hackers mailing list