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

@ -3,6 +3,7 @@
#include <string.h>
#include "cluster.h"
#include "persist.h"
#include "qobj.h"
#include "xce/cluster_def.h"
#include "xce/types.h"
@ -73,6 +74,14 @@ int queue_ctrl(cluster_t* c, xce_queuectrl_t* ctrl)
return -ENOENT;
}
/* bug-447: key_find returns 1 on found (binary librtti, unnormalizable
* upstream). Normalize the found-rc to 0 here so the AFTER_EVENT hook
* gate below fires (WAL append + replication) and the handler's
* commit-barrier pattern sees 0. Real errors are untouched: rc < 0
* returned above, the q == NULL miss returned -ENOENT, and control-
* action failures set rc themselves. */
rc = 0;
lock(q, RTTI_LOCK_WRITE);
switch (ctrl->action) {
case QUEUE_OPEN:
@ -123,7 +132,20 @@ int do_queuecontrol_op(cluster_t* c, endpoint_t* ep, xce_request_t* request)
init_reply_by_req(&reply, request);
rc = queue_ctrl(c, request->body.queuectrlmsg);
rc = queue_ctrl(c, request->body.queuectrlmsg);
/* Commit barrier (ha-commit-barrier-rollout Req 1.1-1.4): the success
* reply is sent only after the operation's WAL entry is majority-
* committed; barrier failures (-ETIMEDOUT, ...) become the error
* reply. Errors from queue_ctrl reply immediately — no barrier wait.
* queue_ctrl released all entity locks before returning, so blocking
* here holds no lock. timeout 0 = configured sync_timeout_ms. */
if (rc == 0) {
rc = persist_commit_barrier(&c->persist, 0);
if (rc != 0)
WARN("%s commit barrier failed, rc %d", __func__, rc);
}
reply.status = rc;
reply.data_which = RequestReply_data_nodata;