forked from lei.chen/myxce
feat(ha-commit-durability): cap commit self-contribution at durable_lsn + durable-advance commit wake (task 2.2)
This commit is contained in:
parent
cc83caf5a0
commit
c41edc515e
10 changed files with 395 additions and 13 deletions
|
|
@ -122,6 +122,19 @@ struct persist_s {
|
|||
pthread_mutex_t fsync_mutex; /* guards the fsync timer wait */
|
||||
pthread_cond_t fsync_cond; /* signaled by persist_stop for prompt join */
|
||||
|
||||
/* Durable-advance wake hook (ha-commit-durability task 2.2).
|
||||
* Persistence owns this slot; the commit engine REGISTERS a callback
|
||||
* (ctx = the commit_engine_t) via persist_set_durable_cb. The flusher
|
||||
* invokes it AFTER advancing durable_lsn and AFTER releasing p->lock,
|
||||
* so a COMMIT_MODE_WAIT caller is woken promptly when its entry becomes
|
||||
* durable locally — without it, a commit whose standby ACKs all arrived
|
||||
* before the local fdatasync would stall until the WAIT timeout. The
|
||||
* dependency direction is preserved (commit depends on persist, never
|
||||
* the reverse): persist only stores+calls an opaque function pointer.
|
||||
* NULL until registered (every flush is then a no-op wake). */
|
||||
void (*on_durable_advance)(void* ctx);
|
||||
void* durable_cb_ctx;
|
||||
|
||||
/* Checkpoint (stubs for now — wired in Task 10) */
|
||||
atomic_int checkpoint_requested;
|
||||
pthread_cond_t checkpoint_done;
|
||||
|
|
@ -206,6 +219,16 @@ int persist_flush(persist_t* p);
|
|||
* any thread. Returns 0 when nothing is yet durable. */
|
||||
uint64_t persist_durable_lsn(persist_t* p);
|
||||
|
||||
/* Register a durable-advance wake callback (ha-commit-durability task 2.2).
|
||||
* The group-commit flusher calls fn(ctx) after it advances durable_lsn and
|
||||
* after releasing p->lock, so a consumer (the commit engine) can re-evaluate
|
||||
* its commit majority and wake any COMMIT_MODE_WAIT caller whose entry just
|
||||
* became durable locally. fn MUST NOT take p->lock (it runs after release, on
|
||||
* the flusher thread) — the commit engine's callback takes only ce->lock,
|
||||
* keeping the lock order p->lock → ce->lock cycle-free. Pass fn = NULL to
|
||||
* unregister. Safe to call before persist_start (no flusher running yet). */
|
||||
void persist_set_durable_cb(persist_t* p, void (*fn)(void* ctx), void* ctx);
|
||||
|
||||
#ifdef XCE_TESTING
|
||||
/* ============================================================
|
||||
* Durability-verification test seam (ha-commit-durability Req 3.2, 3.3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue