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:
parent
efafcdc6e9
commit
6df3bd5906
5 changed files with 117 additions and 21 deletions
|
|
@ -7,6 +7,7 @@
|
|||
#include "xce/cluster_def.h"
|
||||
#include "xce/types.h"
|
||||
#include "xstring.h"
|
||||
#include "wal_types.h"
|
||||
|
||||
void queue_fini(queue_t* q)
|
||||
{
|
||||
|
|
@ -178,3 +179,24 @@ int get_queue_exec(cluster_t* c, char* queue, char** pre_exec, char** post_exec)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Restore queue status flags from a WAL_QUEUE_CTRL entry during recovery.
|
||||
* Queues are built from config at startup; this re-applies admin state changes
|
||||
* (open/close/active/inactive) that were recorded in the WAL. */
|
||||
int restore_queue_state(cluster_t* c, const char* name, uint32_t status)
|
||||
{
|
||||
if (!name || name[0] == '\0')
|
||||
return -EINVAL;
|
||||
|
||||
queue_t* q = NULL;
|
||||
lock(c->qmgr, RTTI_LOCK_READ);
|
||||
key_find(c->qmgr, (void*)name, (void**)&q);
|
||||
unlock(c->qmgr);
|
||||
if (!q)
|
||||
return -ENOENT; /* queue not yet built from config — skip */
|
||||
|
||||
lock(q, RTTI_LOCK_WRITE);
|
||||
q->queue.status = status;
|
||||
unlock(q);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue