diff --git a/.kiro/specs/ha-heartbeat-liveness/tasks.md b/.kiro/specs/ha-heartbeat-liveness/tasks.md index 6d74eec..b63389e 100644 --- a/.kiro/specs/ha-heartbeat-liveness/tasks.md +++ b/.kiro/specs/ha-heartbeat-liveness/tasks.md @@ -79,7 +79,7 @@ - _Boundary: ha.c unit tests_ - _Depends: 2.2_ -- [ ] 4.3 Integration test: 3-node cold start — no false RDHUP loops and race elimination +- [x] 4.3 Integration test: 3-node cold start — no false RDHUP loops and race elimination - Deploy 3-node cluster (ctrl-1 has config, ctrl-2/3 tag=0); verify ctrl-1 elects PRIMARY - Verify ctrl-2/3 receive ctrlhello, set `last_activity`, and do NOT trigger RDHUP before `heartbeat_timeout_ms` elapses from ctrlhello - Verify cluster is stable for 60s with no `hb_timeout_thread` log entries (thread removed) and no RDHUP false-positive entries @@ -87,7 +87,7 @@ - _Requirements: 1.3, 1.4, 4.1, 4.2, 4.3, 5.1, 5.3_ - _Depends: 3.1, 3.2_ -- [ ] 4.4 Integration test: primary crash triggers failover within timeout window +- [x] 4.4 Integration test: primary crash triggers failover within timeout window - Start 3-node cluster; verify ctrl-1 PRIMARY and cluster stable - SIGKILL ctrl-1; verify ctrl-2 or ctrl-3 detects silence within `heartbeat_timeout_ms`; promotes to PRIMARY via RDHUP path - Verify promoted primary serves traffic; verify no infinite RDHUP loop diff --git a/src/controller/ha.c b/src/controller/ha.c index 4f94f7a..4d6e7c0 100644 --- a/src/controller/ha.c +++ b/src/controller/ha.c @@ -434,6 +434,12 @@ static void raft_cb_become_leader(void *ctx, uint64_t term) #else ha_send_ctrlhello_to_all_standbys(c); #endif + /* Start primary heartbeat immediately in COMMITTING so standbys receive + * NOP during the committing window and their liveness poll does not fire. + * ha_start_primary_heartbeat is also called in ha_promote_to_primary; + * the idempotency guard (role check at fn top) prevents double-arming. */ + ha_start_primary_heartbeat(c); + /* Arm committing timeout watchdog */ committing_timeout_ctx_t *ct = calloc(1, sizeof(*ct)); if (ct) {