Title: Automatic failover for a MariaDB primary and replica, without a proxy · Issue #416 · cloudfall-dev/cloudfall · GitHub
Open Graph Title: Automatic failover for a MariaDB primary and replica, without a proxy · Issue #416 · cloudfall-dev/cloudfall
X Title: Automatic failover for a MariaDB primary and replica, without a proxy · Issue #416 · cloudfall-dev/cloudfall
Description: Requested by: @romamo (filed by an agent on his instruction, 2026-11-16) Problem S-019 (#409) gives a MariaDB primary and a replica, and a promotion that happens only when a person changes the declaration and converges. When the primary'...
Open Graph Description: Requested by: @romamo (filed by an agent on his instruction, 2026-11-16) Problem S-019 (#409) gives a MariaDB primary and a replica, and a promotion that happens only when a person changes the decl...
X Description: Requested by: @romamo (filed by an agent on his instruction, 2026-11-16) Problem S-019 (#409) gives a MariaDB primary and a replica, and a promotion that happens only when a person changes the decl...
Opengraph URL: https://github.com/cloudfall-dev/cloudfall/issues/416
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Automatic failover for a MariaDB primary and replica, without a proxy","articleBody":"Requested by: @romamo (filed by an agent on his instruction, 2026-11-16)\n\n## Problem\n\nS-019 (#409) gives a MariaDB primary and a replica, and a promotion that happens only when a person changes the declaration and converges. When the primary's host dies at night, the database is down until someone does that, and every application still points at the dead host.\n\nThree things are missing:\n\n- Nothing watches the pair and decides that the primary is gone\n- Nothing stops a primary that is alive but cut off from taking writes while its replica is promoted, so two servers can end up with different data\n- An application has no way to find the new primary: the address sits in its environment, written by hand\n\n## Proposal\n\nNo proxy in the path. An application on the primary's host keeps the unix socket, the fastest way in, and the application itself finds the primary again after a switch.\n\n1. **One controller** on the management host, a long-running process, the only one that promotes. It keeps one connection open to each server and pings over it every second or two: `read_only`, the GTID position, the server's own write counters, and on the replica the state of its link to the primary. The decision logic runs only after a missed ping\n2. **The replica is the second witness.** The controller promotes only when it cannot reach the primary and the replica reports that it lost the primary too:\n\n | Controller sees the primary | Replica sees the primary | Action |\n |---|---|---|\n | no | yes | The controller's own network; nothing |\n | yes | no | Replication is broken, not the primary; alert, no promotion |\n | no | no | Wait out the primary's self-fence time, then promote |\n | replica unreachable | | Nothing to promote; alert |\n\n3. **A primary fences itself.** A small watchdog on the database host turns `read_only` on when the server can reach neither the controller nor the replica for a set time. The controller promotes only after that time has surely passed. A controller that is down does not stop a primary that still sees its replica\n4. **A server starts read-only.** Writes are switched on by a converge or a promotion, never by a restart, so a primary that comes back after a crash can't take writes beside the new one\n5. **Applications find the primary themselves.** A component's environment carries the fixed list of both servers. On a connection error or a read-only error the application asks each for `read_only`, takes the writable one, reconnects and retries. The truth lives in the servers, so nothing has to be pushed to application hosts during the failure. Cloudfall documents the contract and ships a reference wrapper for Python and PHP\n6. **Health without test writes.** A stalled write path is read from the server's counters in the same ping, and the replica's lag from the two GTID positions; no service table and no binary log noise. An idle primary with a broken write path is found by the first real write: accepted, and a test write stays an option that is off by default\n7. **Monitoring is a separate channel.** A filling disk, a degraded array or rising errors lead to a planned switch before the server fails. Monitoring is never a vote in the failover decision: it is slower than the decision needs, and the decision must not depend on the monitoring stack being up\n8. **A record of every promotion** under the operator's rules (D-19): what each witness saw, the last GTID the replica applied, and so what may have been lost\n\n## Consequences to settle in the spec\n\n- An application that fails over needs an `owner` with a password (S-019): the passwordless unix-socket form works only on the database's own host. Locally it still connects through the socket\n- After a switch, an application left on the old host reaches the primary over TCP with TLS until the primary is moved back\n- On a demotion the controller closes client connections, so no application keeps reading stale data from the old primary\n- Asynchronous replication loses the primary's last transactions; whether semi-synchronous replication is offered is a question for the spec\n- The timings (missed pings, the fence time, the margin before promotion) are chosen in the spec and proven on a pair of hosts\n- The exact counters that show a stalled write, and their behaviour on a full disk, are to be verified on a host before the spec names them\n\n## Alternatives\n\n- **A local proxy on each application host** that follows `read_only`: needs no code in the application, and stays the answer for applications the team can't change. It costs the socket path for an application on the database's host\n- **MaxScale or another tool that promotes by itself:** several deciders with different views of the network\n- **Galera:** a different durability model with three or more servers; out of S-019's scope\n- **A report from the application as a vote:** an application on the primary's host notices a network cut last, its errors often have other causes, and it would let any application trigger a failover. It may later serve as a hint to check at once\n\n## Related\n\n- #409, S-019: the service, the replica and the promotion this builds on\n- #216: connections between components and stores, where the list of servers in a component's environment would come from\n- ROADMAP.md M14: the PostgreSQL failover formation, which needs the same controller, witness and fence\n","author":{"url":"https://github.com/romamo","@type":"Person","name":"romamo"},"datePublished":"2026-11-16T07:31:04Z","url":"https://github.com/cloudfall-dev/cloudfall/issues/416"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:61bb9cff-87d9-840c-0b63-daf8513170b6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BA44:2D8E06:EDD520:144C6EC:6B0558A6 |
| html-safe-nonce | ee8ec5bd591cd0f2d2b68e7683de20a3b1bedccde7016b6babe534507fb4a844 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTQ0OjJEOEUwNjpFREQ1MjA6MTQ0QzZFQzo2QjA1NThBNiIsInZpc2l0b3JfaWQiOiIxNzUzNjkxMTgwODk1NjU2MTAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8e546d623bc21478efb88751431033124bd7cf6864ebf93e0d1643fb573a9c87 |
| hovercard-subject-tag | issue:6416468490 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cloudfall-dev/cloudfall/416/issue_layout |
| twitter:image | https://opengraph.githubassets.com/07ace7022ce5cb7915db0e9daa3fd1b2b6d8d646db4a7ba0af9a5fbe661efd66/cloudfall-dev/cloudfall/issues/416 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/07ace7022ce5cb7915db0e9daa3fd1b2b6d8d646db4a7ba0af9a5fbe661efd66/cloudfall-dev/cloudfall/issues/416 |
| og:image:alt | Requested by: @romamo (filed by an agent on his instruction, 2026-11-16) Problem S-019 (#409) gives a MariaDB primary and a replica, and a promotion that happens only when a person changes the decl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | romamo |
| hostname | github.com |
| expected-hostname | github.com |
| None | a79a02b7e7546ea306864e922ed2103ef4c04fac63168e11c2b2d4d816793080 |
| turbo-cache-control | no-preview |
| go-import | github.com/cloudfall-dev/cloudfall git https://github.com/cloudfall-dev/cloudfall.git |
| octolytics-dimension-user_id | 339512759 |
| octolytics-dimension-user_login | cloudfall-dev |
| octolytics-dimension-repository_id | 1360999777 |
| octolytics-dimension-repository_nwo | cloudfall-dev/cloudfall |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1360999777 |
| octolytics-dimension-repository_network_root_nwo | cloudfall-dev/cloudfall |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 10dff83edfd4f3617a7792a152d44991587b434c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width