forked from lei.chen/myxce
feat(ha-config-bootstrap): implement committed_config_tag and config quorum commit (task 8.1)
This commit is contained in:
parent
684d3b6608
commit
c0cfc1cf83
3 changed files with 20 additions and 3 deletions
|
|
@ -27,7 +27,9 @@
|
|||
#include "byteorder.h"
|
||||
#include "clusterconfig.h"
|
||||
#include "cluster.h"
|
||||
#include "controller.capnp.h" /* OPCode_upgradeConfigAck */
|
||||
#include "ha.h"
|
||||
#include "repl.h" /* repl_wait_majority_ack, repl_on_config_ack */
|
||||
#include "request.h"
|
||||
#include "utils.h"
|
||||
#include "wobj.h"
|
||||
|
|
@ -1119,10 +1121,24 @@ int push_config_to_standbys(cluster_t *c, const uint8_t *bytes, size_t blen,
|
|||
int acked = wait_all_with_timeout(threads, ctxs, n,
|
||||
CONF_PUSH_TIMEOUT_MS, &push_done);
|
||||
|
||||
INFO("Config pushed to %d/%d standbys", acked, n);
|
||||
|
||||
free(ctxs);
|
||||
free(threads);
|
||||
|
||||
/* Req 8.1–8.3: wait for majority-quorum OP_upgradeConfigAck.
|
||||
* On quorum: advance committed_config_tag atomically (Req 8.5). */
|
||||
int rc = repl_wait_majority_ack(&c->persist.repl, CONF_PUSH_TIMEOUT_MS,
|
||||
(uint8_t)OPCode_upgradeConfigAck);
|
||||
if (rc == 0) {
|
||||
atomic_store_explicit(&c->ha.committed_config_tag, new_tag,
|
||||
memory_order_release);
|
||||
INFO("Config committed on majority (tag=%016" PRIx64
|
||||
", pushed=%d/%d standbys)", new_tag, acked, n);
|
||||
} else {
|
||||
WARN("Config push: timeout waiting for majority ACK"
|
||||
" (tag=%016" PRIx64 ", pushed=%d/%d standbys)",
|
||||
new_tag, acked, n);
|
||||
}
|
||||
|
||||
return acked;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue