feat(ha-commit-barrier-rollout): commit-first-then-reply in all four handlers (task 3.2)

Uniform pattern (ctrl fn -> persist_commit_barrier -> reply) in
do_jobcontrol_op/do_queuecontrol_op/do_hostcontrol_op; join barrier
between AFTER_EVENT and success reply (failure -> error reply, skip
on_worker_join). FIXES bug-447: key_find found-rc normalized inside
job_ctrl/queue_ctrl/worker_ctrl — queue/host control now actually
append WAL and replicate (was silently unpersisted); idempotent no-ops
now return 0. handle_jobsubmit untouched. 12/12 + 15/15; census zero
failures.
This commit is contained in:
Rongsong Shen 2026-06-12 10:28:25 +00:00
parent e1c3c173f4
commit facdb90917
7 changed files with 439 additions and 309 deletions

View file

@ -7,6 +7,7 @@
#include "cluster.h"
#include "config_repl.h"
#include "ha.h"
#include "persist.h"
#include "xce/cluster_def.h"
#include "xce/errnox.h"
@ -104,6 +105,21 @@ static int handle_worker_join(cluster_t* c, endpoint_t* ep,
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_AFTER_EVENT,
HOOK_DETAIL_WORKER_JOIN, c, from->name, w);
/* Commit barrier (ha-commit-barrier-rollout Req 1.1-1.4): the success
* reply is sent only after the join's WAL entry is majority-committed;
* barrier failures (-ETIMEDOUT, ...) become the error reply and skip
* on_worker_join below. Join errors (idx < 0) reply immediately — no
* barrier wait. No lock is held here (AFTER_EVENT runs outside any
* lock). timeout 0 = configured sync_timeout_ms. */
if (idx >= 0) {
rc = persist_commit_barrier(&c->persist, 0);
if (rc != 0) {
WARN("%s commit barrier failed for %s, rc %d", __func__,
from->name, rc);
idx = rc;
}
}
reply.status = idx;
reply.data_which = RequestReply_data_nodata;
xce_reply(ep, c->myhost, &reply);