myxce/src/controller
Rongsong Shen aa7fc65a36
fix(controller): cold start elects in ~1.7 s, not ~10 s; ctrlstatus appliedLsn on the primary (bug-1879, bug-1878)
bug-1879: on a fresh HA cluster the config-holding ctrl-1 started its
term-1 election before its peers ran; connect failures count as "no"
votes (bug-1423), so it lost at once and became a follower with no
leader. ctrl-2/ctrl-3 hold no config and are voters only (by design),
so nothing retried until ctrl-1's 10 s standby liveness timeout: every
cold start had no primary for ~10 s.
- ha_note_leaderless() marks a config-holding node that becomes a
  follower with no leader known; the liveness poll then retries the
  election (PreVote) after HA_LEADERLESS_RETRY_MS = 1 s, doubling up to
  heartbeat_timeout_ms. Primary contact or becoming leader clears it.
- ha_heartbeat_is_fresh() answers "no" while leaderless: last_activity
  then only holds the watchdog's arm time, and the failover gates took
  it for a live primary.
Live cold start: primary 1.7 s after the first node started (was ~10 s).

bug-1878: ctrlstatus_fill() reported ha->applied_lsn for every role, a
standby-only counter a primary never advances, so every primary showed
"appliedLsn: 0". A primary now reports persist->last_applied_lsn. The
controller-status design doc's "already correct in every role" note is
corrected.

Tests: 5 new in test_ha_failover_prevote.c, 1 new in test_ctrlstatus.c
(RED: expected 4900, was 0); controller suite 1256/0. HA soaks:
sequential 6 rounds PASS, chaotic 6 rounds PASS (zero divergence, zero
job loss).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 07:35:45 +00:00
..
include fix(controller): a queue added by a live config upgrade exists without a restart (bug-1469) 2026-09-27 06:05:26 +00:00
testsuite fix(controller): cold start elects in ~1.7 s, not ~10 s; ctrlstatus appliedLsn on the primary (bug-1879, bug-1878) 2026-09-28 07:35:45 +00:00
apiserver.c fix(schema): rename struct Data -> XceData to unshadow capnp builtin blob type 2026-07-22 09:22:04 +00:00
CLAUDE.md fix(controller): raft_cb_persist must deny vote and roll back state on persist failure (bug-1684) 2026-08-25 07:49:49 +00:00
cluster.c fix: spurious errors/warnings from a pc13v HA deploy (bug-1872..1877) 2026-09-28 04:35:19 +00:00
commit.c fix(controller): stop a failed test from hanging the unit suite (bug-1429); mkstemp for upgrade temp file (bug-1861) 2026-09-25 13:15:03 +00:00
config_repl.c fix(controller): a queue added by a live config upgrade exists without a restart (bug-1469) 2026-09-27 06:05:26 +00:00
config_repl.h feat(controller): OPCode_probeConfigTag handler with Request envelope reply (bug-1506) 2026-08-10 10:00:08 +00:00
ctrl_metrics.c feat: P3-7 ctrl_metrics — 7 atomic counters/gauges + descriptor table + persist wiring 2026-05-08 00:04:06 +00:00
ctrlstatus.c fix(controller): cold start elects in ~1.7 s, not ~10 s; ctrlstatus appliedLsn on the primary (bug-1879, bug-1878) 2026-09-28 07:35:45 +00:00
dataex.c fix(scheduler,controller): worker resource values always display as 0.00 (bug-1568) 2026-08-17 10:35:34 +00:00
egress.c feat(ha-convergence-recovery): commit-gated scheduler egress — submit_lsn tagging + watermark gate (task 1.2) 2026-06-14 02:33:36 +00:00
ha.c fix(controller): cold start elects in ~1.7 s, not ~10 s; ctrlstatus appliedLsn on the primary (bug-1879, bug-1878) 2026-09-28 07:35:45 +00:00
ha.h fix(controller): cold start elects in ~1.7 s, not ~10 s; ctrlstatus appliedLsn on the primary (bug-1879, bug-1878) 2026-09-28 07:35:45 +00:00
ha_convergence.c fix(controller): offload demotion convergence and catch-up streaming by default (bug-1450, bug-1451) 2026-09-27 05:46:09 +00:00
job.c fix: the controller is the ground truth for job state on scheduler rejoin (bug-1860) 2026-09-27 04:32:37 +00:00
join.c fix(controller): a worker join that fails its commit barrier leaves nothing bound (bug-1728) 2026-09-27 05:48:49 +00:00
main.c fix(bug-1731): fire HOOK_DETAIL_JOB_START/JOB_EXIT on WAL apply 2026-08-29 11:29:10 +00:00
meson.build fix: spurious errors/warnings from a pc13v HA deploy (bug-1872..1877) 2026-09-28 04:35:19 +00:00
misc.c fix(bug-1736): capture memory_swap/tasks_current, compute peak_cpu_time 2026-08-30 15:32:02 +00:00
myapp.c fix: spurious errors/warnings from a pc13v HA deploy (bug-1872..1877) 2026-09-28 04:35:19 +00:00
myconf.c fix(config): serialize load_primary_config against concurrent invocations (bug-1476) 2026-07-28 08:13:54 +00:00
opget.c refactor(controller,xceadmin): drop generic Resource.unit, hardcode bytes for maxmem 2026-08-13 08:27:16 +00:00
opupd.c fix(controller): resource hooks only carry values the controller accepted (bug-1583) 2026-09-27 03:19:17 +00:00
persist.c fix: spurious errors/warnings from a pc13v HA deploy (bug-1872..1877) 2026-09-28 04:35:19 +00:00
queue.c fix(controller): a queue added by a live config upgrade exists without a restart (bug-1469) 2026-09-27 06:05:26 +00:00
repl.c fix(ha): close permanent quorum-loss deadlock on log-conflicted standby (bug-1479) 2026-07-29 04:11:32 +00:00
reply.c fix(persist): zero nresvals_to_sched after free_name_val_list 2026-05-20 09:39:07 +00:00
resources.c update controller code 2025-11-05 16:58:57 +08:00
resync.c fix(controller): persist a failed job's finish_time through WAL_JOB_FAIL (bug-1747) 2026-09-26 09:33:55 +00:00
sched.c fix(bug-1737): scheduler can never learn a job finished successfully 2026-08-31 04:20:27 +00:00
slowlane.c fix(controller): offload demotion convergence and catch-up streaming by default (bug-1450, bug-1451) 2026-09-27 05:46:09 +00:00
startup_validation.c fix(controller): restored-but-stale raft term permanently blocked re-election after restart (bug-1695) 2026-08-25 16:11:37 +00:00
task.c save works 2026-03-04 18:18:53 +08:00
worker.c fix(controller): resource hooks only carry values the controller accepted (bug-1583) 2026-09-27 03:19:17 +00:00