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?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK