fix(election): no-config nodes set CTRL_STANDBY to trigger config fetch; voter-only path

This commit is contained in:
Rongsong Shen 2026-05-31 10:39:33 +00:00
parent a75fb2581b
commit 04b31afb06

View file

@ -2410,6 +2410,9 @@ void ha_start_election_async(ha_state_t *ha, cluster_t *c,
if (my_config_tag == 0 && n_peers > 1) {
INFO("ha_start_election_async: no local config (tag=0, n_peers=%d) — "
"participating as voter only, not starting own election", n_peers);
/* Transition to CTRL_STANDBY so myapp_run schedules fetch_config_from_primary.
* The primary will push config via ctrlhello once it enters COMMITTING. */
atomic_store_explicit(&ha->role, (int32_t)CTRL_STANDBY, memory_order_release);
/* Free ctx — no vote sends will happen from this node this round. */
atomic_store_explicit(&ha->elect_ctx, NULL, memory_order_release);
pthread_mutex_destroy(&ctx->lock);