feat: implement job state, queue state, and worker recovery in WAL replay

WAL payloads:
- Job state transitions (START/FINISH/FAIL/STOP/RESUME/UPDATE etc):
  wal_jobstate_t {uint64_t jobid, uint32_t state} — restores exact state flags
- Queue state (QUEUE_CTRL): wal_queuehdr_t {uint32_t status} + name string —
  re-applies admin open/close/active/inactive after config queues are built
- Worker CTRL: existing [uint32_t detail][capnp xce_worker_t] unchanged

New recovery functions:
- restore_job_state(c, jobid, state): looks up job, overwrites state flags
- restore_queue_state(c, name, status): looks up queue, overwrites status

apply_wal_entry: dispatches all WAL types including job state and queue
test_repl_apply.c: weak stubs for restore_job_state/restore_queue_state
  so unit test binary links without job.c/queue.c
This commit is contained in:
Rongsong Shen 2026-05-08 08:19:20 +00:00
parent efafcdc6e9
commit 6df3bd5906
5 changed files with 117 additions and 21 deletions

View file

@ -41,6 +41,20 @@ int worker_from_capnp(cluster_t* c, const void* capnp_payload, size_t len)
return 0;
}
__attribute__((weak))
int restore_job_state(cluster_t* c, uint64_t jobid, uint32_t state)
{
(void)c; (void)jobid; (void)state;
return 0;
}
__attribute__((weak))
int restore_queue_state(cluster_t* c, const char* name, uint32_t status)
{
(void)c; (void)name; (void)status;
return 0;
}
/* ------------------------------------------------------------------ */
/* Test helpers */
/* ------------------------------------------------------------------ */