myxce/.kiro/specs/ha-elect-ctx-lifecycle
Rongsong Shen 6529dcf08f feat(ha): reference-counted ha_elect_ctx_t lifecycle (ha-elect-ctx-lifecycle)
Replace the deliberate election-carrier leak with an atomic refcount:
a bias reference held by ha->elect_ctx plus one reference per captured
vote endpoint, released via a new endpoint_t.on_fini teardown-completion
hook (fired once, before ep->data is freed). Both real-election and
PreVote capture sites (raft_cb_send_vote_request,
raft_cb_send_pre_vote_request) increment on capture; both publish sites
(ha_start_election_async, ha_start_prevote_async) now atomic_exchange
the outgoing carrier and release it instead of leaking or freeing
outright, so a still-outstanding vote endpoint keeps the superseded
carrier alive until its own teardown completes.

Verified: 758+ controller tests green, isolated LeakSanitizer run shows
zero ha_elect_ctx_t leaks across many election/PreVote rounds, no
premature-free/UAF under supersession, and a live 10-round HA soak
(36 jobs, zero loss, all 3 nodes served as primary).
2026-07-12 04:25:42 +00:00
..
brief.md chore(ha-prevote): resolve log-reason nit; track elect_ctx leak as follow-up spec 2026-06-16 07:56:07 +00:00
design.md feat(ha): reference-counted ha_elect_ctx_t lifecycle (ha-elect-ctx-lifecycle) 2026-07-12 04:25:42 +00:00
requirements.md spec(ha-elect-ctx-lifecycle): generate requirements 2026-07-11 12:16:40 +00:00
research.md feat(ha): reference-counted ha_elect_ctx_t lifecycle (ha-elect-ctx-lifecycle) 2026-07-12 04:25:42 +00:00
spec.json feat(ha): reference-counted ha_elect_ctx_t lifecycle (ha-elect-ctx-lifecycle) 2026-07-12 04:25:42 +00:00
tasks.md feat(ha): reference-counted ha_elect_ctx_t lifecycle (ha-elect-ctx-lifecycle) 2026-07-12 04:25:42 +00:00