pgpool2.git / summary / log / commit / refs
commit 9db83a8841925311f2e463e2bbeb875cf2bc158a
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Fri Aug 12 03:53:46 2016 +0000
Add "replication delay" column to "show pool_nodes".
This column shows the replication delay value in bytes if operated in
streaming replication mode. In other mode, this is always 0.
doc/pgpool-en.html | 10 +++++-----
doc/pgpool-ja.html | 10 +++++-----
src/include/pcp/libpcp_ext.h | 1 +
src/utils/pool_process_reporting.c | 21 ++++++++++++++++++++-
4 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/doc/pgpool-en.html b/doc/pgpool-en.html
index 6d89a08cf..fcf15b6d4 100644
--- a/doc/pgpool-en.html
+++ b/doc/pgpool-en.html
@@ -3438,7 +3438,7 @@ benchs2=# show pool_status;
<h2 id="pool_nodes">pool_nodes <span class="version">V3.0 -</span></h2>
<p>"SHOW pool_nodes" sends back a list of all configured nodes. It
displays the node id, the hostname, the port, the status, the weight (only meaningful
-if you use the load balancing mode), the role, the SELECT query counts issued to each backend and if the node is for load balancing or not. The possible values in the status column
+if you use the load balancing mode), the role, the SELECT query counts issued to each backend, whether the node is for load balancing or not and the streaming replication delay value in bytes if operated in streaming replication mode (in other mode, it is simply 0). The possible values in the status column
are explained in the <a href="#pcp_node_info">pcp_node_info reference</a>.
If the hostname is something like "/tmp", that means pgpool-II is connecting to backend by using UNIX domain sockets. The SELECT count does not include internal queries used by pgoool-II. Also the counters are reset to zero upon starting up of pgpool-II.
</p>
@@ -3447,10 +3447,10 @@ Please note that since pgpool-II <span class="version">3.6</span>, The status co
</p>
<pre>
benchs2=# show pool_nodes;
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node
----------+----------+-------+--------+-----------+---------+------------+-------------------
- 0 | /tmp | 11002 | up | 0.500000 | primary | 9231 | true
- 1 | /tmp | 11003 | up | 0.500000 | standby | 9469 | false
+ node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication delay
+---------+----------+-------+--------+-----------+---------+------------+-------------------+-------------------
+ 0 | /tmp | 11002 | up | 0.500000 | primary | 9231 | true | 0
+ 1 | /tmp | 11003 | up | 0.500000 | standby | 9469 | false | 4248
(2 rows)
</pre>
diff --git a/doc/pgpool-ja.html b/doc/pgpool-ja.html
index 4fc52371c..56403e90e 100644
--- a/doc/pgpool-ja.html
+++ b/doc/pgpool-ja.html
@@ -3365,15 +3365,15 @@ benchs2=# show pool_status;
<h2 id="pool_nodes">pool_nodes <span class="version">V3.0 〜</span></h2>
<p>"SHOW pool_nodes"は、DBノードのリストを表示します。
ホスト名、ポート番号、状態、重み(ロードバランスモードで運用しているときにのみ意味があります)、
-ノードの役割、発行されたSELECTの数、負荷分散対象のノードかどうかが表示されます。
+ノードの役割、発行されたSELECTの数、負荷分散対象のノードかどうか、レプリケーション遅延(単位はバイト、ストリーミングレプリケーションモードの時だけ、それ以外は常に0)が表示されます。
状態(status)の意味については、<a href="#pcp_node_info">pcp_node_infoリファレンス</a>で説明されています。ホスト名が"/tmp"のように表示される場合、UNIXドメインソケットを使用してpgpool-IIがPosgreSQLに接続していることを意味します。SELECTの数には、pgpool-II内部で発行されるクエリの数は含まれません。また、このカウンタはpgpool-IIがスタートした時に0にリセットされます。
</p>
<pre>
benchs2=# show pool_nodes;
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node
----------+----------+-------+--------+-----------+---------+------------+-------------------
- 0 | /tmp | 11002 | 2 | 0.500000 | primary | 9231 | true
- 1 | /tmp | 11003 | 2 | 0.500000 | standby | 9469 | false
+ node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication delay
+---------+----------+-------+--------+-----------+---------+------------+-------------------+-------------------
+ 0 | /tmp | 11002 | up | 0.500000 | primary | 9231 | true | 0
+ 1 | /tmp | 11003 | up | 0.500000 | standby | 9469 | false | 4248
(2 rows)
</pre>
diff --git a/src/include/pcp/libpcp_ext.h b/src/include/pcp/libpcp_ext.h
index 99cb3853b..6243c3aaf 100644
--- a/src/include/pcp/libpcp_ext.h
+++ b/src/include/pcp/libpcp_ext.h
@@ -151,6 +151,7 @@ typedef struct {
char role[POOLCONFIG_MAXWEIGHTLEN+1];
char select[POOLCONFIG_MAXWEIGHTLEN+1];
char load_balance_node[POOLCONFIG_MAXWEIGHTLEN+1];
+ char delay[POOLCONFIG_MAXWEIGHTLEN+1];
} POOL_REPORT_NODES;
/* processes report struct */
diff --git a/src/utils/pool_process_reporting.c b/src/utils/pool_process_reporting.c
index 8aa086834..88a905bc2 100644
--- a/src/utils/pool_process_reporting.c
+++ b/src/utils/pool_process_reporting.c
@@ -1160,11 +1160,20 @@ POOL_REPORT_NODES* get_nodes(int *nrows)
snprintf(nodes[i].load_balance_node, POOLCONFIG_MAXWEIGHTLEN, "%s",
(session_context->load_balance_node_id == i)? "true":"false");
+ snprintf(nodes[i].delay, POOLCONFIG_MAXWEIGHTLEN, "%lld", 0);
+
if (STREAM)
+ {
if (i == REAL_PRIMARY_NODE_ID)
+ {
snprintf(nodes[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "primary");
+ }
else
+ {
snprintf(nodes[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "standby");
+ snprintf(nodes[i].delay, POOLCONFIG_MAXWEIGHTLEN, "%lld", bi->standby_delay);
+ }
+ }
else
{
if (i == REAL_MASTER_NODE_ID)
@@ -1181,7 +1190,7 @@ POOL_REPORT_NODES* get_nodes(int *nrows)
void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
{
- static char *field_names[] = {"node_id","hostname", "port", "status", "lb_weight", "role", "select_cnt", "load_balance_node"};
+ static char *field_names[] = {"node_id","hostname", "port", "status", "lb_weight", "role", "select_cnt", "load_balance_node", "replication delay"};
short num_fields = sizeof(field_names)/sizeof(char *);
int i;
short s;
@@ -1243,6 +1252,11 @@ void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
hsize = htonl(size+4);
pool_write(frontend, &hsize, sizeof(hsize));
pool_write(frontend, nodes[i].load_balance_node, size);
+
+ size = strlen(nodes[i].delay);
+ hsize = htonl(size+4);
+ pool_write(frontend, &hsize, sizeof(hsize));
+ pool_write(frontend, nodes[i].delay, size);
}
}
else
@@ -1260,6 +1274,7 @@ void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
len += 4 + strlen(nodes[i].role); /* int32 + data; */
len += 4 + strlen(nodes[i].select); /* int32 + data; */
len += 4 + strlen(nodes[i].load_balance_node); /* int32 + data; */
+ len += 4 + strlen(nodes[i].delay); /* int32 + data; */
len = htonl(len);
pool_write(frontend, &len, sizeof(len));
s = htons(num_fields);
@@ -1296,6 +1311,10 @@ void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
len = htonl(strlen(nodes[i].load_balance_node));
pool_write(frontend, &len, sizeof(len));
pool_write(frontend, nodes[i].load_balance_node, strlen(nodes[i].load_balance_node));
+
+ len = htonl(strlen(nodes[i].delay));
+ pool_write(frontend, &len, sizeof(len));
+ pool_write(frontend, nodes[i].delay, strlen(nodes[i].delay));
}
}
[parent: 0b99687ed8ee]