myxce/src/controller
Rongsong Shen 0d783b16e3 fix(ha): zero ha_state_t before validation; fix invalid config in stale test
Root cause: test_heartbeat_stale_no_crash_without_primary had
heartbeat_timeout_ms=100 < heartbeat_interval_ms=3000, causing ha_init
to return -EINVAL before memset. The test ignored the return value and
called ha_fini on garbage stack memory. The watchdog_thread field
happened to hold the value 3 (from a prior stack frame), so
ha_stop_watchdog called pthread_join(3, NULL) — crash at 0x2d3
(__pthread_clockjoin_ex accessing thread-struct field at offset 0x2d0).

Fix 1 (test): valid config (interval=2000, timeout=3000). Staleness is
injected via last_heartbeat -= 10s, so timeout value was irrelevant.
Added TEST_ASSERT_EQUAL_INT check on ha_init return.

Fix 2 (ha_init): move memset before validation so ha_fini is safe to
call even after a failed init — prevents the same bug class in callers
that check ha_init's return late.

Verified: test_ha_role 11/11 PASS in both non-ASAN and ASAN builds.
2026-05-20 08:53:38 +00:00
..
include feat: split cluster_init() into phase1/phase2; update myapp_run() for two-phase startup with am_i_primary gating 2026-05-13 17:06:45 +00:00
testsuite fix(ha): zero ha_state_t before validation; fix invalid config in stale test 2026-05-20 08:53:38 +00:00
apiserver.c controller will pass resource <name, value> pair than <idx, value> pair 2026-05-13 07:18:03 +00:00
CLAUDE.md Merge Go frontend (apiserver + xcecli) into meson build 2026-04-14 11:23:18 +08:00
cluster.c fix: capture am_i_primary() result once; set ha->role before phase2; cluster_init wrapper cleanup on failure 2026-05-13 17:32:32 +00:00
config_repl.c feat: filter lost_and_found sentinel from pushes; reset unavail host attrs 2026-05-14 08:44:55 +00:00
config_repl.h feat: filter lost_and_found sentinel from pushes; reset unavail host attrs 2026-05-14 08:44:55 +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
dataex.c feat: filter lost_and_found sentinel from pushes; reset unavail host attrs 2026-05-14 08:44:55 +00:00
ha.c fix(ha): zero ha_state_t before validation; fix invalid config in stale test 2026-05-20 08:53:38 +00:00
ha.h fix: resolve probe_ctx_t type tag, add DEFAULT_MAX_WAL_RECORDS macro, fix atomic type consistency, move ha_seed_jitter to ha.c, add API doc comments 2026-05-13 14:27:07 +00:00
job.c feat: implement job state, queue state, and worker recovery in WAL replay 2026-05-08 08:19:20 +00:00
join.c feat: implement handle_config_request(), fetch_config_from_primary(), handle_controller_join() 2026-05-13 17:46:56 +00:00
main.c fix: validate --conf-keep-n >= 1 and --conf-stale-timeout >= 0 in argument parsing 2026-05-13 16:00:09 +00:00
meson.build feat: add config_repl Phase 1 — HEAD-file storage, SHA-256, trim, stale check, sanitise_cn 2026-05-13 15:45:28 +00:00
misc.c save works 2026-03-05 16:03:37 +08:00
myapp.c fix: capture am_i_primary() result once; set ha->role before phase2; cluster_init wrapper cleanup on failure 2026-05-13 17:32:32 +00:00
myconf.c feat: implement handle_config_request(), fetch_config_from_primary(), handle_controller_join() 2026-05-13 17:46:56 +00:00
opget.c controller will pass resource <name, value> pair than <idx, value> pair 2026-05-13 07:18:03 +00:00
opupd.c save works 2026-03-03 16:49:26 +08:00
persist.c feat: add schedule_checkpoint() with WAL record-count trigger and idempotency CAS guard 2026-05-13 17:56:46 +00:00
queue.c feat: implement job state, queue state, and worker recovery in WAL replay 2026-05-08 08:19:20 +00:00
repl.c feat: P2-5 repl_start/complete_catchup, repl_needs_snapshot — standby catch-up state 2026-05-07 18:14:12 +00:00
reply.c controller will pass resource <name, value> pair than <idx, value> pair 2026-05-13 07:18:03 +00:00
resources.c update controller code 2025-11-05 16:58:57 +08:00
sched.c controller will pass resource <name, value> pair than <idx, value> pair 2026-05-13 07:18:03 +00:00
task.c save works 2026-03-04 18:18:53 +08:00
worker.c feat(worker-join-refactor): implement apply_join_state, init_worker, rejoin_worker 2026-05-20 08:24:26 +00:00