forked from lei.chen/myxce
fix(ha): fix config replication to standbys; add replConfigPush handler
- config_repl.c: add handle_repl_config_push — standby handler for OPCode_replConfigPush. Verifies SHA-256, saves blob to disk via conf_save_config, reloads via load_primary_config, ACKs primary. - config_repl.h: declare handle_repl_config_push. - cluster.c: dispatch OPCode_replConfigPush to handle_repl_config_push; populate c->myhost_info.name from myconf->name (ctrl-1/ctrl-2/ctrl-3) instead of the static "controller" placeholder. - ha.c: fix raft_cb_become_leader push_config_to_standbys call to pass real config bytes and tag read from disk (was NULL/0 — standbys got empty push and never saved config). - typemap.h: add raw_sha256/raw_bytes/raw_bytes_len fields to repl_config_push_req_t (mirrors upgrade_config_req_t pattern). - request.c: pre-extract List(UInt8) sha256/bytes from OPCode_replConfigPush before capn_free() in xce_decode(); free them in xce_free_request(). - helper.c: add all HA/replication opcode names to xce_request_op_name so "unknown opcode 30" becomes "replConfigPush" in logs. - cluster_def.h: add embedded myhost_info field to cluster_t struct. - ha.h: declare ha_start_primary_heartbeat; remove dead ha_find_and_connect_to_primary declaration.
This commit is contained in:
parent
d00d3bb051
commit
3d076ccda6
8 changed files with 191 additions and 8 deletions
|
|
@ -403,12 +403,27 @@ static void raft_cb_become_leader(void *ctx, uint64_t term)
|
|||
}
|
||||
|
||||
if (c) {
|
||||
/* Push config to standbys with lower config_tag */
|
||||
/* Push config to standbys — read raw bytes from disk so standbys
|
||||
* can save the file. NULL bytes are passed only in test mode. */
|
||||
#ifdef XCE_TESTING
|
||||
if (ha_push_config_hook != NULL)
|
||||
ha_push_config_hook(c);
|
||||
#else
|
||||
push_config_to_standbys(c, NULL, 0, NULL, 0);
|
||||
{
|
||||
uint8_t *cfg_bytes = NULL;
|
||||
size_t cfg_len = 0;
|
||||
extern int conf_read_raw(const char *, uint8_t **, size_t *);
|
||||
if (c->myconf && c->myconf->conffile &&
|
||||
conf_read_raw(c->myconf->conffile, &cfg_bytes, &cfg_len) == 0) {
|
||||
push_config_to_standbys(c, cfg_bytes, cfg_len,
|
||||
c->myconf->config_sha256,
|
||||
c->myconf->config_version_tag);
|
||||
free(cfg_bytes);
|
||||
} else {
|
||||
push_config_to_standbys(c, NULL, 0, NULL,
|
||||
c->myconf ? c->myconf->config_version_tag : 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* Send CtrlHelloRequest to all standbys to trigger WAL catch-up */
|
||||
#ifdef XCE_TESTING
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue