pgpool2.git / summary / log / commit / refs

commit    0535317dc16c0b46b104db166a1e02e55e410cfc
Author:   Tatsuo Ishii <ishii at sraoss.co.jp>
Date:     Thu May 05 02:39:14 2011 +0000

    Fix incorrect calculation of LSN in bytes.
    
    Change pg_last_xlog_receive_location() to
    pg_last_xlog_replay_location() because the latter respects actually
    replayed location which will give less chance for clients to have
    stale data in standby.
    
    Fix suggested by Anton Yuzhaninov.


pool_worker_child.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pool_worker_child.c b/pool_worker_child.c index 612cedaee..014190e66 100644 --- a/pool_worker_child.c +++ b/pool_worker_child.c @@ -233,7 +233,7 @@ static void check_replication_time_lag(void) } else { - query = "SELECT pg_last_xlog_receive_location()"; + query = "SELECT pg_last_xlog_replay_location()"; } sts = do_query(slots[i]->con, query, &res, PROTO_MAJOR_V3); @@ -307,6 +307,12 @@ static void check_replication_time_lag(void) */ static long text_to_lsn(char *text) { +/* + * WAL segment size in bytes. XXX We should fetch this from + * PostgreSQL, rather than having fixed value. + */ +#define WALSEGMENTSIZE 16 * 1024 * 1024 + unsigned int xlogid; unsigned int xrecoff; unsigned long long int lsn; @@ -316,7 +322,10 @@ static long text_to_lsn(char *text) pool_error("text_to_lsn: wrong log location format: %s", text); return 0; } - lsn = xlogid * 16 * 1024 * 1024 * 255 + xrecoff; + lsn = xlogid * ((unsigned long long int)0xffffffff - WALSEGMENTSIZE) + xrecoff; +#ifdef DEBUG + pool_log("lsn: %X %X %llX", xlogid, xrecoff, lsn); +#endif return lsn; } [parent: a628fddfb845]