pgpool2.git / summary / log / commit / refs
commit 28fac240f90d3c96984ff1006f9856a50dc6d500
Author: Yugo Nagata <nagata@sraoss.co.jp>
Date: Fri Mar 29 11:56:23 2013 +0000
Fix to calculate replication delay only if standby server is
behind from the primay server.
When the primary server is behind from standby server, negative
value of delay is calculated and the value is assigned to unsigned
variable. It causes a log message informing negative replication
delay. And what is worse, it also causes SELECT queries to be sent
to the primary in load balance even though there are no replication
delay in fact.
The problem is reported and analyzed by Saitoh Hidenori in
[pgpoolgenera-jp: 1145]. (in Japanese)
pool_worker_child.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/pool_worker_child.c b/pool_worker_child.c
index f52e7cbde..c8db8ba76 100644
--- a/pool_worker_child.c
+++ b/pool_worker_child.c
@@ -290,7 +290,7 @@ static void check_replication_time_lag(void)
/* Set standby delay value */
bkinfo = pool_get_node_info(i);
- lag = lsn[PRIMARY_NODE_ID] - lsn[i];
+ lag = (lsn[PRIMARY_NODE_ID] > lsn[i]) ? lsn[PRIMARY_NODE_ID] - lsn[i] : 0;
if (PRIMARY_NODE_ID == i)
{
@@ -301,12 +301,13 @@ static void check_replication_time_lag(void)
bkinfo->standby_delay = lag;
/* Log delay if necessary */
- if (!strcmp(pool_config->log_standby_delay, "always") ||
+ if ((!strcmp(pool_config->log_standby_delay, "always") && lag > 0) ||
(pool_config->delay_threshold &&
!strcmp(pool_config->log_standby_delay, "if_over_threshold") &&
lag > pool_config->delay_threshold))
{
- pool_log("Replication of node:%d is behind %lld bytes from the primary server (node:%d)", i, lsn[PRIMARY_NODE_ID] - lsn[i], PRIMARY_NODE_ID);
+ pool_log("Replication of node:%d is behind %llu bytes from the primary server (node:%d)",
+ i, lsn[PRIMARY_NODE_ID] - lsn[i], PRIMARY_NODE_ID);
}
}
}
[parent: 92ba9b7993a1]