Who promotes a replica when the source dies, and how do they know it is really dead?
Orchestrator is a service that reads your replication tree, judges failures by asking the replicas, and promotes a new source. It works with plain asynchronous replication and GTIDs.
You run one MySQL source and a few replicas with plain asynchronous replication. The source dies. Somebody has to pick the replica that has the most data, promote it, re-point every other replica to it and tell the app where writes go now. Doing that by hand, under pressure, is slow and easy to get wrong. Orchestrator is the tool that does it for you, and it does it by watching the replicas, not just the source.
Writes. With async replication the replicas are fine and the data is there, but nobody is accepting writes until a replica is promoted and the app is pointed at it.
A failover decided by the replicas, not by one health check. GitHub reports "between 10 and 13 seconds of total outage time in most cases" with Orchestrator, Consul and a proxy layer (source below).
The same tool does a graceful takeover: make the source read-only, let the chosen replica catch up, promote it, demote the old source. Patching the source becomes a command, not a night shift.
Not a proxy and not a backup. It tells your proxy or DNS where the writer is through hooks. A bad DELETE still reaches every replica, so you still need backups and point-in-time recovery.
consul-template updates the HAProxy-based load balancer. They report 10 to 13 seconds of outage in most cases, up to 20 seconds in less frequent cases and up to 25 seconds in extreme ones. They also say a lossless failover is expected but not guaranteed, and not expected on a full data center failure. (MySQL High Availability at GitHub)The original openark/orchestrator repository was archived on February 18, 2025. On April 9, 2026, ProxySQL announced it is taking over maintenance at github.com/ProxySQL/orchestrator. Release 4.30.0 was the first ProxySQL release (Apache 2.0). It adds Prometheus metrics, Kubernetes health endpoints and ProxySQL hostgroup integration. The latest tag on that repository is v4.32.1, and this page pins to it. Orchestrator was developed at Outbrain, Booking.com and GitHub. Percona says it welcomes the move. Its Operator for MySQL uses Orchestrator to manage asynchronous topologies (see MySQL on Kubernetes).
Not on async replication? InnoDB Cluster has its own failover in Group Replication and does not need Orchestrator. Orchestrator is for the classic source and replicas setup.
Before tools like MHA and Orchestrator, a failover was a checklist you ran from a terminal. Say the source, db1, loses power. Here is the checklist, with MySQL 8.4 syntax and GTIDs on.
SET GLOBAL super_read_only = ON.SELECT @@global.gtid_executed and compare. The replica whose set contains the most transactions is the furthest ahead.STOP REPLICA; RESET REPLICA ALL; then SET GLOBAL super_read_only = OFF; SET GLOBAL read_only = OFF;.STOP REPLICA; CHANGE REPLICATION SOURCE TO SOURCE_HOST='db2', SOURCE_AUTO_POSITION=1; START REPLICA;.Why not script all of that? People did, and those scripts are the ancestors of this tool. The hard parts are the decisions: is the source really dead or is the network flaky, which replica to promote when the most advanced one is on old hardware or in the wrong data center, and what to do when a second thing breaks mid-failover.
Step through it:
A health check on the source alone cannot tell "the source is dead" from "my network blinked". Act on a blink and you promote a replica while the old source is still taking writes. That is split brain.
Orchestrator is a service that connects to every MySQL server in your replication topologies, reads their replication status, and draws the tree: who replicates from whom. It can show it, move replicas around the tree, and fail over. Its failure detection asks the replicas too. A dead source means the source cannot be reached and its replicas confirm they cannot see it either.
| Part | What it does | Notes |
|---|---|---|
| orchestrator service | Probes every instance each InstancePollSeconds (5 in the sample config), builds the topology, runs detection every second, runs recoveries. | HTTP API and web UI on :3000 by default. |
| Backend database | Stores what it learned: instances, topology, audit and recovery history. | MySQL or the bundled SQLite. SQLite is fine for a lab or for raft nodes, where each node has its own. |
| orchestrator/raft | 3 or 5 nodes agree on a leader. Only the leader acts. | Solves Orchestrator's own availability and cross-data-center isolation. |
| orchestrator-client | A shell wrapper over the HTTP API. Finds the leader if you give it every node. | Set ORCHESTRATOR_API. |
| Hooks | Your commands before and after a recovery, plus built-in Consul KV and ProxySQL support. | A non-zero exit from a pre-failover hook aborts the recovery. |
| Proxy or discovery layer | Sends the app to the current writer: ProxySQL, HAProxy with Consul, DNS. | Not part of Orchestrator. |
Step through it:
Pinned versions on this page: Orchestrator v4.32.1 from github.com/ProxySQL/orchestrator (4.30.0 was the release in ProxySQL's April 2026 announcement), MySQL 8.4 LTS. Start with one Orchestrator node and a SQLite backend in a lab. Move to three nodes with raft before production.
log_replica_updates. Set a short replica heartbeat so a replica notices a dead source fast:# my.cnf on every server [mysqld] server_id = 11 # unique per server gtid_mode = ON enforce_gtid_consistency = ON log_bin = binlog log_replica_updates = ON binlog_format = ROW report_host = db1.example.com # so Orchestrator finds replicas by name replica_net_timeout = 4 # heartbeat every 2 s, replica gives up after 4 s -- on each replica, once CHANGE REPLICATION SOURCE TO SOURCE_HOST='db1.example.com', SOURCE_USER='repl', SOURCE_PASSWORD='...', SOURCE_AUTO_POSITION=1, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=86400; START REPLICA;
CREATE USER 'orchestrator'@'orc_host' IDENTIFIED BY 'a-long-secret'; GRANT SUPER, PROCESS, REPLICATION SLAVE, REPLICATION CLIENT, RELOAD ON *.* TO 'orchestrator'@'orc_host'; GRANT SELECT ON meta.* TO 'orchestrator'@'orc_host';
github.com/ProxySQL/orchestrator (tag v4.32.1) and install it./etc/orchestrator.conf.json. This one detects everything and recovers nothing until you opt a cluster in:{
"ListenAddress": ":3000",
"BackendDB": "sqlite",
"SQLite3DataFile": "/var/lib/orchestrator/orchestrator.db",
"MySQLTopologyCredentialsConfigFile": "/etc/mysql/orchestrator-topology.cnf",
"InstancePollSeconds": 5,
"DiscoverByShowSlaveHosts": true,
"ReasonableReplicationLagSeconds": 10,
"RecoveryPeriodBlockSeconds": 3600,
"RecoverMasterClusterFilters": [],
"RecoverIntermediateMasterClusterFilters": [],
"ApplyMySQLPromotionAfterMasterFailover": true,
"PreventCrossDataCenterMasterFailover": true,
"DetachLostReplicasAfterMasterFailover": true,
"PreFailoverProcesses": ["/usr/local/bin/orc-pre-failover {failureCluster} {failedHost}"],
"PostMasterFailoverProcesses": ["/usr/local/bin/orc-post-failover {failureCluster} {successorHost}:{successorPort}"]
} The credentials file is a MySQL option file: [client] with user=orchestrator and password=.... RecoveryPeriodBlockSeconds: 3600 is the anti-flapping block: after a recovery on a cluster, Orchestrator will not auto-recover that cluster again for an hour unless a human acknowledges it. A pre-failover hook that exits non-zero aborts the recovery, so it is a good place for a last safety check.
systemctl start orchestrator export ORCHESTRATOR_API=http://orc:3000/api orchestrator-client -c discover -i db1.example.com:3306 orchestrator-client -c clusters orchestrator-client -c topology -i db1.example.com:3306
clusters, never "*" on day one:"RecoverMasterClusterFilters": ["orders"]
From 4.30.0, Orchestrator can update ProxySQL hostgroups during a failover without custom scripts. It drains the old source, then promotes the new one in the writer hostgroup and runs LOAD MYSQL SERVERS TO RUNTIME and SAVE MYSQL SERVERS TO DISK. A ProxySQL outage does not block the MySQL failover.
"ProxySQLAdminAddress": "127.0.0.1", "ProxySQLAdminPort": 6032, "ProxySQLAdminUser": "admin", "ProxySQLAdminPassword": "...", "ProxySQLWriterHostgroup": 10, "ProxySQLReaderHostgroup": 20, "ProxySQLPreFailoverAction": "offline_soft"
Check it with orchestrator-client -c proxysql-test and -c proxysql-servers. With a ProxySQL Cluster, point Orchestrator at one node and let ProxySQL sync the rest.
"RaftEnabled": true, "RaftDataDir": "/var/lib/orchestrator", "RaftBind": "orc1.example.com", "DefaultRaftPort": 10008, "RaftNodes": ["orc1.example.com", "orc2.example.com", "orc3.example.com"]
Each node keeps its own backend (SQLite is fine). Only the leader acts. Put the three nodes in three failure domains, then set ORCHESTRATOR_API to all three URLs and orchestrator-client will find the leader. For Kubernetes, 4.30.0 adds /health/live, /health/ready and /health/leader endpoints.
Three servers. db1 is the source, db2 and db3 replicate from it. Automatic recovery is on for this cluster, ProxySQL hooks are on, and the app writes through ProxySQL.
Step through it:
Planned work uses the same machinery without a crash. graceful-master-takeover-auto sets the source read-only, waits for the chosen replica to catch up, promotes it, turns it writable and makes the old source a replica of the new one. Expect a few seconds of write errors while the source is read-only.
All of these go through orchestrator-client against the API. Set ORCHESTRATOR_API first. -alias and --alias both work, and -i takes host:port.
orchestrator-client -c clusters # clusters Orchestrator knows orchestrator-client -c clusters-alias # same, with aliases orchestrator-client -c topology -i db1:3306 # ASCII tree of that topology orchestrator-client -c which-master -i db2:3306 # who is the source of this instance orchestrator-client -c replication-analysis # what Orchestrator thinks is broken now orchestrator-client -c api -path audit-recovery # recovery history, raw JSON orchestrator-client -c which-api # which API endpoint the client picked
orchestrator-client -c graceful-master-takeover-auto -alias orders # it picks the replica orchestrator-client -c graceful-master-takeover-auto -alias orders -d db2:3306 # you pick the replica orchestrator-client -c graceful-master-takeover -alias orders -d db2:3306 # old source is placed below it, replication not started
orchestrator-client -c recover -i db1:3306 # recover a failed instance Orchestrator agrees is failed; ignores the block period orchestrator-client -c force-master-failover --alias orders # fail over now, even if Orchestrator sees no problem orchestrator-client -c ack-cluster-recoveries -alias orders # acknowledge a recovery, unblocking the next one orchestrator-client -c ack-all-recoveries
orchestrator-client -c relocate -i db3:3306 -d db2:3306 # put db3 below db2; Orchestrator picks the method orchestrator-client -c relocate-replicas -i db2:3306 -d db4:3306 # move all replicas of db2 below db4 orchestrator-client -c stop-replica -i db3:3306 orchestrator-client -c start-replica -i db3:3306 orchestrator-client -c set-read-only -i db3:3306 orchestrator-client -c register-candidate -i db2:3306 --promotion-rule prefer # prefer, neutral, prefer_not, must_not; expires after an hour
orchestrator-client -c disable-global-recoveries # no automatic recovery anywhere orchestrator-client -c check-global-recoveries # shows whether recoveries are enabled orchestrator-client -c enable-global-recoveries
A server that was the old source comes back with data nobody else has, or with a different GTID set. Do not blindly relocate it. Check gtid_executed against the new source first, and rebuild it from a backup if it has errant transactions.
ProxySQL: orchestrator-client -c proxysql-test checks the connection, -c proxysql-servers lists the runtime server table.
| Symptom | Likely cause | First check | Fix |
|---|---|---|---|
| Source died and nothing happened | The cluster is not in RecoverMasterClusterFilters, recoveries are disabled globally, the block period is active, or a pre-failover hook exited non-zero. | check-global-recoveries, api -path audit-recovery, the Orchestrator log. | Fix the cause, then recover -i HOST:PORT. Manual recovery ignores the block and the filters. |
| Analysis says UnreachableMaster, no failover | Replicas still reach the source. Often a network path problem between Orchestrator and MySQL. | Can the replicas replicate? replication-analysis. | Fix the path. Do not force a failover while replicas are happy with the source. |
| Writes block, source is up | LockedSemiSyncMaster: semi-sync is on, too few replicas ack, and the timeout is high. | replication-analysis, semi-sync status variables on the source. | Bring replicas back or relax the timeout. Orchestrator only acts if you set RecoverLockedSemiSyncMaster or EnforceExactSemiSyncReplicas. |
| Failover aborted: replica too far behind | FailMasterPromotionOnLagMinutes or FailMasterPromotionIfSQLThreadNotUpToDate did their job. | Lag on the candidate, relay log backlog. | Decide: recover the lost transactions from the relay logs or binlogs, or force the promotion. |
| App still writes to the old source | The proxy or DNS hook failed. Post-failover hook errors are logged, and the recovery stays successful unless FailRecoveryOnFailedPostFailoverProcesses is true. | Where does the writer name point? proxysql-servers. | Fix the hook. Set FailRecoveryOnFailedPostFailoverProcesses if discovery is part of your SLO. |
| Old source comes back and takes writes | Split brain: nothing stopped it. | Is it read-only? Does it have errant GTIDs? | Make it read-only at boot, fence it, rebuild it. GitHub says this gap exists for apps inside an isolated data center and they work on a STONITH approach. |
| Orchestrator itself is gone | Single node, or shared backend that failed. | /health/ready, /health/leader. | Run raft with 3 or 5 nodes in separate failure domains. |
| Replica cannot be re-pointed | No GTID auto-position, no log_replica_updates, or replication filters. | The replica's settings against the requirements list. | Fix the settings. Orchestrator needs GTID, Pseudo-GTID or binlog servers. |
From 4.30.0, Orchestrator serves Prometheus metrics at /metrics (on by default, PrometheusEnabled). The metric names in the docs:
| Signal | Where | Alert when |
|---|---|---|
orchestrator_recoveries_total (labels type, result) | Prometheus, scrape orc:3000/metrics | Any failed result, or any recovery at all, if you want a page for each failover. |
orchestrator_recovery_duration_seconds | Prometheus | Longer than your RTO budget. |
orchestrator_discovery_errors_total | Prometheus | Rising: a server cannot be probed. |
orchestrator_instances_total, orchestrator_clusters_total | Prometheus | Drops: a cluster fell out of discovery. |
/health/leader, /health/ready | Load balancer or Kubernetes probe | Not exactly one leader. |
replication-analysis | CLI or /api/replication-analysis | Anything other than empty. |
| Replication lag and heartbeat | pt-heartbeat or your metrics, plus ReplicationLagQuery | Lag above ReasonableReplicationLagSeconds. Lag drives promotion decisions. |
Also keep the recovery audit page (/web/audit-recovery) in the runbook. Related playbooks: Something is slow or broken, Synchronous replication and failover.
Every change is shown to you first and runs only after you type an approval. Reads run straight away.
python3 -m dbagent.ha orc status --api http://orc:3000 python3 -m dbagent.ha orc takeover --cluster ALIAS [--to HOST:PORT] python3 -m dbagent.ha orc recover --instance HOST:PORT python3 -m dbagent.ha orc relocate --instance HOST:PORT --below HOST:PORT python3 -m dbagent.ha orc ack --cluster ALIAS python3 -m dbagent.ha orc pause python3 -m dbagent.ha orc resume
takeover is the planned switchover. pause and resume turn global recoveries off and on. recover, relocate and ack match the client commands above.
How do databases actually work? From one row on disk to transactions: the words you need, PostgreSQL, MySQL and MongoDB from the files up, then Redis, Cassandra and vector search, side by side, and the query and concurrency traps.