fix(mariadb): linearize primary write acceptance with HA authority#3208
Draft
weicao wants to merge 7 commits into
Draft
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## helen/mariadb-open-prs-combined-20260714t164119z-v3 #3208 +/- ##
====================================================================================
Coverage 0.00% 0.00%
====================================================================================
Files 150 153 +3
Lines 23752 24124 +372
====================================================================================
- Misses 23752 24124 +372 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
added 6 commits
July 15, 2026 04:26
leon-ape
marked this pull request as draft
July 15, 2026 03:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and runtime evidence
Fresh focused r9 on addon source
378d7934e8d2f0b167035275b5c5ca7d77a9627band syncer10ee54d8ec86f5d04db0fc6f7628fcde46b2432chit a first non-environment red during planned switchover.The addon secondary reconcile fenced the candidate with global
read_only=ONwhile syncer promoted that same Pod. Full addon primary acceptance took about five seconds; syncer then treated the fenced leader as unhealthy and released the new lease.Frozen focused boundary (
N=1, full suite not launched): Promote1 -> 1, marker present25/25, old primary unavailable25/25, candidate writable23/25, lease refresh1 -> 1, expiry0 -> 14. Evidence outer SHA256 isd6281be829a6f749e27ed316cf80d41b8a3fba277f07ddc17d4796588e94c581; root manifest SHA256 is58d7a21ab4b32c70c70fe7bb6015a9c810106e2faa9cd8944682e46669a873b4(65/65). Natural convergence after the failure window does not turn r9 into a PASS.Rejected designs
The following addon exacts and the previous cross-layer pair are withdrawn and must not be packaged or launched:
7e23d315...: opened global read-only early and incorrectly described it as an internal-only write plane.fde4576b...: left the production order opening user writers before required gates.137f9c47...: checked preStop only before the internal gate and failed to restore the strongest fence on post-gate DCS drift.efd452617...: added more fresh reads, but an independent production-function interleaving proved that completed preStop fencing and DCS drift could still be overwritten at the first open. Audit SHA256eb65c682b9edd20db961aa6fb900a77bad7dd350c7e12fc3f1151ca334ff5fc2; repro SHA256e5be68045e687d98a369d262b7489d0b2886ff1073eae8d4340ad2a100624c78.786f9188...+ syncer9742c492...: serialized the first open but still left root unlock and readiness publication after the authoritative HTTP commit. It also let recurring/repair callers use a stalegetrole==primaryobservation as direct-open authority. The old preStop path additionally continued marker/SQL mutation after its five-second lock budget expired.More snapshots or a shorter post-response tail cannot make a read-followed-by-write sequence atomic. This revision removes those windows.
Corrected linearizable contract
Addon exact
8aca6a21bbedf400312f0820c56e1540fed222e3works with syncer PR #304 exact8cfcc248fccf9b0d7011ce78db8831342a0714b8:set_primary_read_writeowns an atomic local commit lock through its complete acceptance attempt.ON, which still fences ordinary user writers.syncerctl primary-write-commitas the last visible commit operation. After HTTP success the addon only releases its local lock and emits a neutral acknowledgement log; it does not open writes, unlock accounts, or publish readiness.resourceVersionCAS, opens and reads back MariaDB global writes, clears pending/divergence, and publishes.primary-read-write-readyplus.replication-ready(the latter last) before returning success.Demotepublishes pending and removes both ready markers before it tightens MariaDB read-only. If that transition fails, demotion fails and the switchover handler does not release the lease.Demotebefore lease release and recovery. Demote failure must renew DCS authority; if renewal fails, it fail-stops and positively verifies the local DB is no longer running. These branches never release or recover a writable/ready old primary, and incomplete fail-stop is reportedfail_closed=false.default-pod0-primarybootstrap with no DCS lease may use the addon-owned standard path.Promoteprepares replication only. It never opens writes or publishes readiness.1before any marker or SQL mutation. Kubelet process termination is the truthful exceptional fail-close boundary, so this branch does not claim durable strongest-fence or root-lock state.Rollback still distinguishes a complete strongest fence plus both root locks (
rc=2) from incomplete rollback (rc=3,fail_closed=false). MariaDBNO_LOCK_NO_ADMINremains the required complete rollback state becauseONpermits the addon-ownedREAD_ONLY ADMINaccount to write.TDD and source verification
The tests extract and execute production functions rather than wrapper-only substitutes.
|| true; the new production harness holds acceptance beyond the old budget and proves timeout means zero marker/SQL mutation before process termination.96examples,0failures.101examples,0failures.766examples =757pass /0fail /9historical pending.201pass /0fail /6historical pending.bash -n,sh -n, ShellCheck severity=error,helm template, andgit diff --check: PASS.go test ./... -count=1, focusedgo test -race, andgo vet ./...: PASS on the paired exact.CI, review, and runtime boundary
Both heads are pushed, remote-exact, clean, OPEN, non-draft, and mergeable. Addon official CI is complete on
8aca6a21...; syncer official CI is running for the new8cfcc248...correction. The complete syncer CI on5e6e11e0...and checks on047a97d2...do not validate the authority-continuity amendment. Earlier green review/checker results remain scoped to the paths they covered.Runtime for the corrected pair is
N=0. This PR update is not a Test GO. After both official CIs, Magnus's new-head addon review, and Jack's independent production checker close, Dev must freshly enumerate every current weicao open PR touching MariaDB, build a new combined source, and publish a new exact manifest. Test independently owns package, render, runner, live identity, focused runtime evidence, cleanup, and any later full-suite decision.