forked from lei.chen/myxce
feat(ha-convergence-recovery): commit-gated scheduler egress — submit_lsn tagging + watermark gate (task 1.2)
This commit is contained in:
parent
7ff81156c2
commit
b9ddfa60cb
9 changed files with 241 additions and 67 deletions
|
|
@ -30,8 +30,8 @@
|
|||
#include <zlib.h>
|
||||
|
||||
/* restore_* functions defined in job.c / worker.c / queue.c */
|
||||
extern int restore_job(cluster_t* c, uint64_t jobid,
|
||||
const void* capnp_payload, size_t len);
|
||||
extern int restore_job(cluster_t* c, uint64_t jobid, const void* capnp_payload,
|
||||
size_t len, uint64_t entry_lsn);
|
||||
extern int restore_job_state(cluster_t* c, uint64_t jobid, uint32_t state);
|
||||
extern int worker_from_capnp(cluster_t* c,
|
||||
const void* capnp_payload, size_t len);
|
||||
|
|
@ -729,8 +729,10 @@ int apply_wal_entry(persist_t* p, const wal_entry_hdr_t* hdr, const void* payloa
|
|||
|
||||
switch (hdr->type) {
|
||||
case WAL_JOB_SUBMIT:
|
||||
/* Payload: Cap'n Proto serialized xce_job_t */
|
||||
restore_job(p->cluster, 0, payload, hdr->payload_len);
|
||||
/* Payload: Cap'n Proto serialized xce_job_t. Thread the entry LSN
|
||||
* through so the restored job is tagged for the egress watermark
|
||||
* (ha-convergence-recovery 3.3). */
|
||||
restore_job(p->cluster, 0, payload, hdr->payload_len, hdr->lsn);
|
||||
break;
|
||||
|
||||
case WAL_JOB_START:
|
||||
|
|
@ -1326,10 +1328,30 @@ int persist_job_hook_fun(int type, int situation, int detail,
|
|||
* even when replication is degraded (no standbys → -ENODEV, timeout
|
||||
* → -ETIMEDOUT). Only abort the loop on a real disk-write failure
|
||||
* (non-zero return). Replication status is informational here. */
|
||||
/* ha-convergence-recovery (3.3): snapshot the LSN this submit
|
||||
* entry will receive BEFORE the append. persist_wal_async assigns
|
||||
* hdr.lsn = current_lsn then increments (persist.c:318), so the
|
||||
* pre-append current_lsn is exactly the written entry's LSN — the
|
||||
* same value persist_wal_sync_append derives as current_lsn - 1. */
|
||||
pthread_mutex_lock(&p->lock);
|
||||
uint64_t submit_lsn = p->current_lsn;
|
||||
pthread_mutex_unlock(&p->lock);
|
||||
|
||||
int sync_rc = 0;
|
||||
rc = persist_wal_sync_append(p, WAL_JOB_SUBMIT, buf, (uint32_t)sz,
|
||||
&sync_rc);
|
||||
free(buf);
|
||||
|
||||
/* Tag the job with its submit entry's LSN whenever the LOCAL WAL
|
||||
* write succeeded. persist_wal_sync_append returns the
|
||||
* persist_wal_async error only on local-write failure; on a
|
||||
* replication-degraded outcome (0 / -ETIMEDOUT / -ENODEV /
|
||||
* -XCE_ERR_NOT_READY) the entry was appended locally and the LSN
|
||||
* advanced, so the tag must be set (the egress predicate is
|
||||
* independent of replication status). */
|
||||
if (rc == 0 || rc == -ETIMEDOUT || rc == -XCE_ERR_NOT_READY) {
|
||||
j->submit_lsn = submit_lsn;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue