fix: the fence of an old MariaDB primary ends its connections (keel#186, keel#193) #190
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Keel-Linux/keel!190
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/mariadb-fence-kills-waiting-writes-186"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #186. Fixes #193. Stacked on #189 (keel#106) → #187 → main: merge those first. The fence of this PR alone comes at the release; #197 moves it to the doubt of the lease.
On a cut MariaDB primary, acknowledged writes were lost at a failover (measured in the cross-site rehearsal: 12 of 1906 acknowledged ids lost, see #186):
rpl_semi_sync_master_timeout = 10000is shorter than the VIP's release (15 s, keel#174). A write that waits for the replica's ACK returned OK after 10 s, and the next writes returned OK at once, until the old primary dropped the VIP.SET GLOBAL read_only = ONwaits for the backup lock behind the waiting write, which then returns OK when the timeout ends.And #193: a dump thread to the cut replica stayed on the old primary. When that replica later connected again with the same server id, MariaDB 11.8.6 ended the old thread and then took no connection at all. Reproduced locally with a relay that stops moving bytes and keeps its sockets; a
KILLof the stale thread ends it cleanly, and the reconnect then works.What changes:
keel.system.dbreadonly.fence:SET GLOBAL read_only = ONin a client of its own (waits until its statement shows, sent again if a kill ended it), and while it waits,KILL CONNECTIONof every connection but the server's own threads and this node's own replication threads; one more pass after it. A waiting write gets an error and no OK; the dump threads of its replicas end, because a fenced node serves no replica.keel database followuses it when it turns a node read only that took writes.rpl_semi_sync_master_timeout = 30000. With #197 (keel#195) the fence starts at the doubt of the lease; rehearsal 3 measured the cut to read only at 6.1 to 8.8 s, so 10 s would leave 1.2 s in the worst case and 30 s leaves room. A lost replica still gives the fallback, 30 s after the last ACK. This changes the 10 s of the maintainer's answer of 2026-10-03 (0031); the handbook amendment records it.docs/replication.mdsays it.Tests:
tests/test_mariadb_fence_real.pyon two realmariadbd(semi-synchronous, AFTER_SYNC): the waiting write gets no OK,read_onlyis on well within the timeout, a new write is refused; with the black-hole relay, the dump thread ends and the server answers after the replica connects again with the same server id. Runs in "mariadb / trixie" as root (also as follow runs it, no seams). Without the kills the tests fail (checked).keel 0.23.36.
4a6fa9907dc2fc854a51c2fc854a5181858ed17a81858ed17ae3c6afa214fix: the fence of an old MariaDB primary ends its client connections (keel#186)to fix: the fence of an old MariaDB primary ends its connections (keel#186, keel#193)e3c6afa214ebe37aee59ebe37aee5998bcface9d