In GBase 8a, the China-domestically developed MPP analytical database from GBASE, the gcware service cluster shares information between the GCluster instances on every node — cluster topology, node states, node resource states — and, during multi-replica data operations, decides which nodes are usable and controls data-consistency state. A gcware cluster has several nodes, usually an odd number: one is elected leader, the rest are followers, and the leader holds the most current data. This post shows how to find out which node that is.
The gcware Log
By default it is stored at:
INSTALL_DIR/gcware/log/gcware.log
The Leader Marker
When a node becomes leader, the log records this line, where XXXXX is a number:
switch to leader with term:XXXXX
Filtering on switch to shows the whole election trail — candidate → leader as well as candidate → follower:
grep "switch to" /opt/gbase/*/gcware/log/gcware.log | tail
Finding the Current Leader
Look for the latest Leader marker on each gcware node. The one with the most recent date (to avoid being misled by clock skew) and the largest number is the Leader. Here is the output from two nodes.
Node 103:
[gbase@gbase_rh7_003 ~]$ grep "switch to" /opt/gbase/*/gcware/log/gcware.log | tail
Feb 07 17:29:44.546192 INFO [GCWARE] node 1728184330 switch to candidate
Feb 07 17:29:47.887201 INFO [GCWARE] node 1728184330 switch to candidate
Feb 07 17:29:50.295710 INFO [GCWARE] node 1728184330 switch to candidate
Feb 07 17:29:50.320778 INFO [GCWARE] node 1728184330 switch to leader with term:123
Feb 09 08:41:20.388174 INFO [GCWARE] node 1728184330 switch to follower with term:124 leader:0
Feb 09 08:41:22.456324 INFO [GCWARE] node 1728184330 switch to follower with term:125 leader:0
Feb 09 08:41:24.643133 INFO [GCWARE] node 1728184330 switch to follower with term:126 leader:0
Feb 10 09:56:37.339436 INFO [GCWARE] node 1728184330 switch to follower with term:126 leader:0
Feb 10 09:56:39.503562 INFO [GCWARE] node 1728184330 switch to candidate
Feb 10 09:56:41.279513 INFO [GCWARE] node 1728184330 switch to follower with term:205 leader:0
Node 104:
[gbase@gbase_rh7_004 log]$ grep "switch to " /opt/gbase/*/gcware/log/gcware.log | tail
Feb 09 09:14:37.059239 INFO [GCWARE] node 1744961546 switch to candidate
Feb 09 09:14:40.076193 INFO [GCWARE] node 1744961546 switch to candidate
Feb 10 09:56:21.190265 INFO [GCWARE] node 1744961546 switch to follower with term:199 leader:0
Feb 10 09:56:24.842071 INFO [GCWARE] node 1744961546 switch to candidate
Feb 10 09:56:27.875309 INFO [GCWARE] node 1744961546 switch to candidate
Feb 10 09:56:30.875920 INFO [GCWARE] node 1744961546 switch to candidate
Feb 10 09:56:33.957789 INFO [GCWARE] node 1744961546 switch to candidate
Feb 10 09:56:37.263772 INFO [GCWARE] node 1744961546 switch to candidate
Feb 10 09:56:41.272030 INFO [GCWARE] node 1744961546 switch to candidate
Feb 10 09:56:41.519532 INFO [GCWARE] node 1744961546 switch to leader with term:205
The newest entry on node 103 is February 7, with term 123; on node 104 it is February 10. An election took place at February 10 09:56:41, making 104 the leader and 103 a follower.
Going forward, you will rarely need this — the cluster coordinates elections on its own. It matters only after an outage such as a power loss, when some nodes' gcware files are corrupted and must be repaired by hand: that is when you need to know which surviving gcware copy in gbase holds the newest data. Comparing dates and term numbers in the log is far more reliable than guessing from a node number.
Top comments (0)