MemSQL achieves high availability with pairs on different machines. This allows either host to experience problems and the data will still be available, as all of the data is on each of the pairs.
If you have an odd number of hosts, without careful set up, the final, odd host will be paired to itself. Having a host paired to itself presents a potential issue if that host is ever down the entire pair is unavailable.
Such a configuration observable from the output of SHOW leaves;
The host 10.0.3.167 is paired to itself in this example.
We need to strategically add and pair leaves so that no two pairs are on the same host, or add an additional host.
For most purposes the best solution is to add an additional host; unless there is a necessary restriction on the number of hosts.
First we need to take down a leaf on the host paired to itself. Do this with:
DETACH LEAF '<HOST>':<PORT>;
In this case it would be:
DETACH LEAF '10.0.3.167':3308;
Then verify it has been detached as pictured and exit memsql:
Now we need to delete the detached leaf, we do this so that it does not try to pair with that leaf again later.
Delete the leaf with:
Select the detached leaf, which in this case is at index 4, and delete:
Next, we need to add an additional host, once another host is online, that can be verify with:
from master aggregator as pictured:
Now, we have 4 hosts, so we need to add a leaf on the new machine for the unpaired leaf to pair to.
memsql-ops memsql-deploy -a <ID> -r leaf -P <PORT> --availability-group <GROUP>
It's important to use the ID from the agent list of the new machine, and the availability group of the leaf we deactivated. We deactivated a leaf in availability-group 2, so the new one needs to be availability group 2.
Now we can bring up 2 more leaves, 1 on the host we deleted the leaf from, and the other on the new host.
Use a similar memsql-deploy, changing the agent id and port:
Now, go back to the memsql prompt and run a show leaves to verify that no host is paired to itself:
Now each leaf should have a buddy, avoiding issues should the unlucky host becomes unavailable. The new configuration should look like:
So, no pair will go down with a single host failure.