forked from lei.chen/myxce
feat(ha-commit-engine): honest write-admission quorum accounting (task 4.2)
repl_active_standby_count: registry truth (ep != NULL && !in_catch_up) under r->lock. ha_state_t gains repl back-pointer (wired at init by task 5.3); ha_has_write_quorum uses registry truth when wired, exact legacy fallback when NULL; formula unchanged. Test 29 (wired gate, catch-up-only standby → NOT_READY, admits after clear) captured RED pre-fix. 29/29 group tests; suite at the 3-failure baseline.
This commit is contained in:
parent
b2598823c0
commit
c9154bd5cc
6 changed files with 92 additions and 11 deletions
|
|
@ -550,12 +550,28 @@ int repl_needs_snapshot(replicator_t *r, uint64_t standby_lsn,
|
|||
* Write-admission quorum accounting (ha-commit-engine task 4)
|
||||
* ============================================================ */
|
||||
|
||||
/* RED scaffold for task 4.1: deliberately inert so the task-4.1 tests fail
|
||||
* on assertions rather than at link time (-1 is never a valid count).
|
||||
* The real counting — slots with ep != NULL && !in_catch_up under r->lock —
|
||||
* is implemented in task 4.2. */
|
||||
/* repl_active_standby_count — registry-truth count of standbys able to
|
||||
* receive new log entries: slots with ep != NULL && !in_catch_up, evaluated
|
||||
* under r->lock. NULL registry counts zero. Consumed by ha_has_write_quorum
|
||||
* (ha.c) for write admission. Takes ONLY r->lock — never the commit-engine
|
||||
* mutex (lock-ordering rule: gate path holds no locks when calling in).
|
||||
* (ha-commit-engine Req 3.1, 3.2, 3.3) */
|
||||
int repl_active_standby_count(replicator_t *r)
|
||||
{
|
||||
(void)r;
|
||||
return -1;
|
||||
int i;
|
||||
int count = 0;
|
||||
|
||||
if (!r)
|
||||
return 0;
|
||||
|
||||
mylock_lock(&r->lock);
|
||||
for (i = 0; i < MAX_STANDBYS; i++) {
|
||||
if (r->standbys[i].ep != NULL &&
|
||||
!atomic_load_explicit(&r->standbys[i].in_catch_up,
|
||||
memory_order_acquire))
|
||||
count++;
|
||||
}
|
||||
mylock_unlock(&r->lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue