Counting Partitions by Role

The output of SHOW CLUSTER STATUS is useful for understanding the state of partition databases in a SingleStore cluster. This output can be used to determine if the number of primary partitions is equal to the number of replica partitions. A SingleStore cluster configured for High Availability (HA) should always have the same number of primary and replica partition databases.

The purpose of this article is to provide commands for counting the number of primary and replica partitions in a SingleStore cluster.

Consider the following output of SHOW CLUSTER STATUS:

show cluster status;
+------------+------+----------------+-----------+-------------+------------+---------+
| Host       | Port | Database       | Role      | State       | Position   | Details |
+------------+------+----------------+-----------+-------------+------------+---------+
| 10.0.0.105 | 3307 | memsql_demo    | Reference | replicating | 0:14778    |         |
| 10.0.0.105 | 3307 | memsql_demo_0  | Master    | online      | 0:12959258 |         |
| 10.0.0.105 | 3307 | memsql_demo_10 | Replica   | replicating | 0:13044214 |         |
| 10.0.0.105 | 3307 | memsql_demo_12 | Master    | online      | 0:12965513 |         |
| 10.0.0.105 | 3307 | memsql_demo_14 | Replica   | replicating | 0:12856488 |         |
| 10.0.0.105 | 3307 | memsql_demo_2  | Replica   | replicating | 0:13043324 |         |
| 10.0.0.105 | 3307 | memsql_demo_4  | Master    | online      | 0:12930755 |         |
| 10.0.0.105 | 3307 | memsql_demo_6  | Replica   | replicating | 0:12980970 |         |
| 10.0.0.105 | 3307 | memsql_demo_8  | Master    | online      | 0:12906009 |         |
| 10.0.1.26  | 3307 | memsql_demo    | Reference | replicating | 0:14778    |         |
| 10.0.1.26  | 3307 | memsql_demo_0  | Replica   | replicating | 0:12959258 |         |
| 10.0.1.26  | 3307 | memsql_demo_10 | Master    | online      | 0:13044214 |         |
| 10.0.1.26  | 3307 | memsql_demo_12 | Replica   | replicating | 0:12965513 |         |
| 10.0.1.26  | 3307 | memsql_demo_14 | Master    | online      | 0:12856488 |         |
| 10.0.1.26  | 3307 | memsql_demo_2  | Master    | online      | 0:13043324 |         |
| 10.0.1.26  | 3307 | memsql_demo_4  | Replica   | replicating | 0:12930755 |         |
| 10.0.1.26  | 3307 | memsql_demo_6  | Master    | online      | 0:12980970 |         |
| 10.0.1.26  | 3307 | memsql_demo_8  | Replica   | replicating | 0:12906009 |         |
| 10.0.2.34  | 3307 | memsql_demo    | Reference | replicating | 0:14778    |         |
| 10.0.2.34  | 3307 | memsql_demo_1  | Master    | online      | 0:13064181 |         |
| 10.0.2.34  | 3307 | memsql_demo_11 | Replica   | replicating | 0:12880457 |         |
| 10.0.2.34  | 3307 | memsql_demo_13 | Master    | online      | 0:13001894 |         |
| 10.0.2.34  | 3307 | memsql_demo_15 | Replica   | replicating | 0:13066662 |         |
| 10.0.2.34  | 3307 | memsql_demo_3  | Replica   | replicating | 0:12980834 |         |
| 10.0.2.34  | 3307 | memsql_demo_5  | Master    | online      | 0:13029848 |         |
| 10.0.2.34  | 3307 | memsql_demo_7  | Replica   | replicating | 0:12944227 |         |
| 10.0.2.34  | 3307 | memsql_demo_9  | Master    | online      | 0:13074322 |         |
| 10.0.2.1   | 3307 | memsql_demo    | Reference | replicating | 0:14778    |         |
| 10.0.2.1   | 3307 | memsql_demo_1  | Replica   | replicating | 0:13064181 |         |
| 10.0.2.1   | 3307 | memsql_demo_11 | Master    | online      | 0:12880457 |         |
| 10.0.2.1   | 3307 | memsql_demo_13 | Replica   | replicating | 0:13001894 |         |
| 10.0.2.1   | 3307 | memsql_demo_15 | Master    | online      | 0:13066662 |         |
| 10.0.2.1   | 3307 | memsql_demo_3  | Master    | online      | 0:12980834 |         |
| 10.0.2.1   | 3307 | memsql_demo_5  | Replica   | replicating | 0:13029848 |         |
| 10.0.2.1   | 3307 | memsql_demo_7  | Master    | online      | 0:12944227 |         |
| 10.0.2.1   | 3307 | memsql_demo_9  | Replica   | replicating | 0:13074322 |         |
+------------+------+----------------+-----------+-------------+------------+---------+
36 rows in set (0.00 sec)

Use the following one-line command to determine number of primary partition databases in a cluster:

memsql-master-agg-host /home/admin $ singlestore -e "show cluster status" | cut -f4 -d$'\t' | grep Master | wc -l
16

Use the following one-line command to determine number of Orphan partition databases in a cluster

memsql-master-agg-host /home/admin $ singlestore -e "show cluster status" | cut -f4 -d$'\t' | grep Orphan | wc -l
0

Any orphaned partitioned databases found in the output of SHOW CLUSTER STATUS should be addressed immediately. The topic Understanding Orphaned Partitions provides an example of addressing an orphan.

Last modified: June 13, 2024

Was this article helpful?