feat(ha-config-bootstrap): implement ha_wait_for_heartbeat_or_timeout (task 3.4)
- sem_timedwait on heartbeat_seen semaphore with CLOCK_REALTIME deadline - deadline = now + election_timeout_ms + xorshift64 jitter - Returns CTRL_STANDBY on heartbeat arrival (calls ha_do_demote) - Returns CTRL_ELECTING on timeout (caller drives election) - Allows OPCode_heartbeat through dispatch gate in CTRL_INIT state - 3 new unit tests: standby-on-heartbeat, electing-on-timeout, gate-allows-heartbeat - 24 Tests 0 Failures in test_ha_startup suite
This commit is contained in:
parent
72776f18ff
commit
f0029bf000
4 changed files with 202 additions and 1 deletions
|
|
@ -76,7 +76,7 @@ Dependency order: startup validation (D) unblocks vtaskmgr before election (A);
|
|||
- _Requirements: 1.3, 1.4_
|
||||
- _Boundary: Controller FSM (ha.c, cluster.c)_
|
||||
|
||||
- [ ] 3.4 Implement ha_wait_for_heartbeat_or_timeout()
|
||||
- [x] 3.4 Implement ha_wait_for_heartbeat_or_timeout()
|
||||
- `sem_timedwait(&c->ha.heartbeat_seen, &deadline)` where `deadline = now + election_timeout_ms + xorshift64_jitter()`
|
||||
- Heartbeat handler posts `heartbeat_seen` only when `ha.role == CTRL_INIT`; receiving a heartbeat transitions to `CTRL_STANDBY` and returns
|
||||
- Election timeout fires → returns without setting standby; caller proceeds to `am_i_primary_quorum()`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue