fix(election-iomgr-refactor): Raft election, config decode, and RDHUP chain
- ha.c: self-vote in ha_start_election_async (Raft invariant) - ha.c: heartbeat_timeout_ms for hb_timeout_thread (not election_timeout_ms) - ha.c: clear voted_for before RDHUP jitter (stale vote from dead primary) - ha.c: same-term voted_for check in RDHUP jitter - config_repl.c/h: use xce_decode for upgradeConfig (capnp extraction before capn_free) - cluster.c: fix upgradeConfig handler direction (standbys apply, primaries skip) - cluster.c: remove raw_pkt_copy hack; use req directly - join.c: push config to newly-joined standbys - typemap.h/request.h/request.c: raw_sha256/raw_bytes fields for decoded upgradeConfig - test_ha_failover.c: update heartbeat timeout test to use g_fast_cfg
This commit is contained in:
parent
1ded1022fb
commit
dbb750ebd3
8 changed files with 198 additions and 102 deletions
|
|
@ -1335,41 +1335,33 @@ static int do_upgrade_config_with_bytes(cluster_t *c, endpoint_t *ep,
|
|||
}
|
||||
|
||||
#if CONF_ENABLE_UPGRADE_CONFIG
|
||||
int handle_upgrade_config(cluster_t *c, endpoint_t *ep, xce_request_t *req,
|
||||
const uint8_t *raw_pkt, size_t raw_pkt_sz)
|
||||
int handle_upgrade_config(cluster_t *c, endpoint_t *ep, xce_request_t *req)
|
||||
{
|
||||
/* xce_decode() extracted sha256 + bytes from the wire into
|
||||
* req->body.upgradeconfigrequestmsg->raw_sha256 / raw_bytes before
|
||||
* capn_free() ran. Use them directly — no raw packet copy needed. */
|
||||
uint8_t *in_bytes = NULL;
|
||||
size_t in_len = 0;
|
||||
uint8_t *in_sha = NULL;
|
||||
|
||||
int rc = xce_upgrade_config_req_extract_raw(raw_pkt, raw_pkt_sz,
|
||||
&in_bytes, &in_len, &in_sha);
|
||||
int rc = xce_upgrade_config_req_extract(req, &in_bytes, &in_len, &in_sha);
|
||||
if (rc != 0 || !in_bytes || !in_sha) {
|
||||
send_upgrade_error(ep, req, c,
|
||||
"Failed to extract bytes from UpgradeConfigRequest");
|
||||
free(in_bytes);
|
||||
free(in_sha);
|
||||
return rc != 0 ? rc : -EINVAL;
|
||||
}
|
||||
if (in_len == 0) {
|
||||
free(in_bytes);
|
||||
free(in_sha);
|
||||
send_upgrade_error(ep, req, c, "bytes or sha256 field missing");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = do_upgrade_config_with_bytes(c, ep, req, in_bytes, in_len, in_sha);
|
||||
free(in_bytes);
|
||||
free(in_sha);
|
||||
return rc;
|
||||
/* in_bytes and in_sha are owned by req — do NOT free here */
|
||||
return do_upgrade_config_with_bytes(c, ep, req, in_bytes, in_len, in_sha);
|
||||
}
|
||||
#else
|
||||
int handle_upgrade_config(cluster_t *c, endpoint_t *ep, xce_request_t *req,
|
||||
const uint8_t *raw_pkt, size_t raw_pkt_sz)
|
||||
int handle_upgrade_config(cluster_t *c, endpoint_t *ep, xce_request_t *req)
|
||||
{
|
||||
(void)c;
|
||||
(void)raw_pkt;
|
||||
(void)raw_pkt_sz;
|
||||
xce_reply_t reply;
|
||||
init_reply_by_req(&reply, req);
|
||||
reply.status = -ENOSYS;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue