fix(ha-config-bootstrap): start iomgr and vtaskmgr before election so vote RPCs are accepted

This commit is contained in:
Rongsong Shen 2026-05-29 12:11:12 +00:00
parent 96df7285da
commit 4e9924e95c
2 changed files with 14 additions and 2 deletions

View file

@ -1081,8 +1081,13 @@ int cluster_start(cluster_t* c)
return rc;
}
iomgr_start(&(c->iomgr));
vtaskmgr_start(&(c->vtaskmgr));
/* Guard: myapp_run() starts iomgr and vtaskmgr before election so that
* incoming OP_requestVote RPCs are accepted during the election phase.
* Only start here if they were not already started (legacy cluster_init path). */
if (c->iomgr.worker == 0)
iomgr_start(&(c->iomgr));
if (c->vtaskmgr.dispatcher == 0)
vtaskmgr_start(&(c->vtaskmgr));
delaymgr_start(&(c->delaymgr));
/* Start persistence fsync thread and register WAL hooks */

View file

@ -68,6 +68,13 @@ int myapp_run(myconf_t* myconf)
vtaskmgr_init(&(c.vtaskmgr), nvcpus);
}
/* Req 1.2: start the I/O worker thread so that incoming OP_requestVote RPCs
* from peers are accepted and dispatched during the election phase.
* Without iomgr_start here, connections queue in the kernel (Recv-Q > 0)
* but no thread reads them, causing peers to time out waiting for vote replies. */
iomgr_start(&(c.iomgr));
vtaskmgr_start(&(c.vtaskmgr));
/* Req 3.1–3.4: probe peers for config tags before election so that a node
* joining an existing cluster knows to defer its config fetch to post-election
* rather than participating as a first-boot candidate with no config. */