fix(ha-term): move ha-term.bin to {workdir}/{name}/data/ alongside WAL/snapshot
This commit is contained in:
parent
04b31afb06
commit
0f766776ba
2 changed files with 13 additions and 6 deletions
|
|
@ -791,13 +791,15 @@ int cluster_init_phase1(cluster_t* c)
|
|||
}
|
||||
|
||||
/* Restore persisted election term + voted_for from ha-term.bin (Req 9.2).
|
||||
* ha_persist_term() already writes on vote grant; this reads it back at
|
||||
* startup so the restarted node remembers its last term. */
|
||||
if (c->myconf->workdir) {
|
||||
rc = ha_restore_term(&c->ha, c->myconf->workdir);
|
||||
* File lives under {workdir}/{myname}/data/ alongside WAL and snapshot. */
|
||||
if (c->myconf->workdir && c->myconf->name) {
|
||||
char term_dir[1024];
|
||||
snprintf(term_dir, sizeof(term_dir), "%s/%s/data",
|
||||
c->myconf->workdir, c->myconf->name);
|
||||
rc = ha_restore_term(&c->ha, term_dir);
|
||||
if (rc == 0) {
|
||||
INFO("HA: restored term=%lu from %s/ha-term.bin",
|
||||
(unsigned long)atomic_load(&c->ha.term), c->myconf->workdir);
|
||||
(unsigned long)atomic_load(&c->ha.term), term_dir);
|
||||
} else if (rc != -ENOENT) {
|
||||
WARN("HA: ha_restore_term failed: %d", rc);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue