fix(ha-bootstrap): register listener with iomgr epoll before election

vote_request_thread connects to peers via SSL. iomgr was started before
election but c->ep was only registered with epoll inside cluster_start(),
which runs after election. The TCP connect succeeded (kernel accepts it)
but SSL_accept was never called server-side, so SSL_connect failed
immediately — both vote threads went to deny in <1ms and ctrl-a could
never win a quorum.

Fix: add cluster_register_listener() that wires c->ep into iomgr's
epoll watch. Call it from myapp_run() right after iomgr_start/vtaskmgr_start,
before election. cluster_start() still calls iomgr_monitor again
(idempotent via EPOLL_CTL_MOD).
This commit is contained in:
Rongsong Shen 2026-05-30 00:10:23 +00:00
parent 6753b364c8
commit fe37f4d692
3 changed files with 30 additions and 0 deletions

View file

@ -75,6 +75,19 @@ int myapp_run(myconf_t* myconf)
iomgr_start(&(c.iomgr));
vtaskmgr_start(&(c.vtaskmgr));
/* Register the listener socket with epoll NOW so that iomgr can accept
* and dispatch incoming OP_requestVote connections during the election.
* Without this, iomgr runs but has no fd to watch — SSL_connect from
* peers succeeds at TCP level but hangs waiting for SSL_accept. */
{
int monitor_rc = cluster_register_listener(&c);
if (monitor_rc < 0) {
ERROR("cluster_register_listener: %s", strerror(-monitor_rc));
cluster_fini(&c);
return monitor_rc;
}
}
/* Pre-load config from disk if a local config file exists, so that this
* node's config_tag is known before election. This allows the freshness gate
* in am_i_primary_quorum() (Req 2.4) to work correctly: a node with a valid