Skip to content

Instantly share code, notes, and snippets.

@robrich
Last active August 10, 2021 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robrich/3b5ee06a1bc179f3c5cfce0055def5d4 to your computer and use it in GitHub Desktop.
Save robrich/3b5ee06a1bc179f3c5cfce0055def5d4 to your computer and use it in GitHub Desktop.
MemSQL load-balanced failover queries.sql
-- MemSQL load-balanced failover
-- =============================
-- Queries demoing load-balanced failover in MemSQL: https://youtu.be/J86fLCMr5dc
create database x_db partitions 8;
select host, port, node_id, availability_group as AG from leaves order by AG;
SELECT master_host as m_host, master_port as m_port, host as repl_host, port as repl_port, GROUP_CONCAT(database_name ORDER BY database_name) AS list_partitions FROM information_schema.mv_cluster_status WHERE metadata_role='slave' GROUP BY master_host, master_port, repl_host, repl_port ORDER BY master_host, master_port, repl_host, repl_port;
set global leaf_failover_fanout='load_balanced';
rebalance partitions on x_db;
SELECT master_host as m_host, master_port as m_port, host as repl_host, port as repl_port, GROUP_CONCAT(database_name ORDER BY database_name) AS list_partitions FROM information_schema.mv_cluster_status WHERE metadata_role='slave' GROUP BY master_host, master_port, repl_host, repl_port ORDER BY master_host, master_port, repl_host, repl_port;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment