region HA P1a final fix: F1 every post-start HA release proves the host slice empty
One proof, haHostEmpty (the sleep's hostSliceEmpty read), now gates every HA release after a start: releaseHAClean, cleanupFailedWake, the start-error shortcuts (giveBackAfterStart) and the reaper. Unproven, the wake is retained with its lease and replica, no marker is written, and the reaper retries. Witnesses: a foreign replacement invocation after a failed wake's stop (no marker, another box refused), a failed start leaving the slice populated, and the reaper over a populated slice. The simulation's failed wake can leave a straggler; rule failed-wake-before-slice-empty and its witness catch a release that skips the proof.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 files changed,
+303
−22
internal/activator/activator.go+2 −2internal/activator/harelease.go+36 −10internal/activator/harelease_test.go+144 −0internal/activator/maintenance.go+49 −0internal/activator/opset.go+14 −2internal/sim/regionha/actions_test.go+36 −3internal/sim/regionha/rules_test.go+5 −4internal/sim/regionha/sim_test.go+1 −1internal/sim/regionha/witness_test.go+16 −0
diff --git a/internal/activator/activator.go b/internal/activator/activator.go| index 36245f6c4..410e0b575 100644 |
| --- a/internal/activator/activator.go |
| +++ b/internal/activator/activator.go |
| @@ -2646,13 +2646,13 @@ func (a *Service) doWake(ctx context.Context, e *actEntry) (*wokenInstance, erro |
| // spawn. Its stop is known, not uncertain (seeded pre-land |
| // review, P2; census ruling 292fix). |
| w.stopOutcome.notStarted() |
| - w.stopOutcome.leaseReleased = a.giveBack(ctx, host, lease) |
| + a.giveBackAfterStart(ctx, rt, w, lease) |
| case launchNotStarted(err): |
| // Something of this wake is running after all: it goes through |
| // the failed wake's cleanup and its proofs, not the shortcut. |
| a.cleanupFailedWake(ctx, e, rt, w, lease) |
| default: |
| - w.stopOutcome.leaseReleased = a.giveBack(ctx, host, lease) |
| + a.giveBackAfterStart(ctx, rt, w, lease) |
| } |
| return w, fmt.Errorf("start %s: %w", host, err) |
| } |
diff --git a/internal/activator/harelease.go b/internal/activator/harelease.go| index 57725d68f..f07e3d136 100644 |
| --- a/internal/activator/harelease.go |
| +++ b/internal/activator/harelease.go |
| @@ -112,6 +112,39 @@ func (b *ExecBackend) writeHARecord(rt registry.Route, m hafresh.Marker, files h |
| return writeReleaseRecord(p, rt.Host, hafresh.LocalRecord{Marker: m, DB: now.DB, WALEmpty: now.WALEmpty, TreeDigest: now.TreeDigest}) |
| } |
| +// haHostEmpty is the one whole-host emptiness proof every HA release |
| +// after a start makes (r3.2, final review F1): the sleep's |
| +// (releaseHAClean), a failed wake's (cleanupFailedWake, giveBackAfterStart) |
| +// and its reaper's (reapUnprovenWake). A process's own proof (its exit, its |
| +// generation's cgroup) is not enough: a replacement invocation, or anything |
| +// else of the host, may still run in the host's slice. nil only when the |
| +// slice reads absent or unpopulated; otherwise an errHostSliceUnproven, |
| +// and the caller keeps ownership: no marker, the lease held, a retry later. |
| +func (a *Service) haHostEmpty(rt registry.Route) error { |
| + hb, ok := a.backend.(haReleaser) |
| + if !ok { |
| + return fmt.Errorf("%w: this backend cannot read it", errHostSliceUnproven) |
| + } |
| + empty, err := hb.hostSliceEmpty(rt) |
| + if err != nil { |
| + return fmt.Errorf("%w: %v", errHostSliceUnproven, err) |
| + } |
| + if !empty { |
| + return fmt.Errorf("%w: it holds a process", errHostSliceUnproven) |
| + } |
| + return nil |
| +} |
| + |
| +// haHeld reports whether a wake's lease or replica is an HA one: its |
| +// release is a marker, and goes only over haHostEmpty. |
| +func haHeld(l Lease, r Rep) bool { |
| + if hr, ok := r.(haRep); ok && hr.HA() { |
| + return true |
| + } |
| + hl, ok := l.(haLease) |
| + return ok && hl.HA() |
| +} |
| + |
| // haEntryRep is e's replica as an HA one, if it is. |
| func haEntryRep(e *actEntry) (haRep, bool) { |
| r, ok := e.rep.(haRep) |
| @@ -140,17 +173,10 @@ func (a *Service) releaseHAClean(ctx context.Context, e *actEntry) error { |
| if !ok || !hr.HA() { |
| return errors.New("not an HA replica") |
| } |
| - hb, ok := a.backend.(haReleaser) |
| - if !ok { |
| - return fmt.Errorf("%w: this backend cannot read it", errHostSliceUnproven) |
| - } |
| - empty, err := hb.hostSliceEmpty(rt) |
| - if err != nil { |
| - return fmt.Errorf("%w: %v", errHostSliceUnproven, err) |
| - } |
| - if !empty { |
| - return fmt.Errorf("%w: it holds a process", errHostSliceUnproven) |
| + if err := a.haHostEmpty(rt); err != nil { |
| + return err |
| } |
| + hb := a.backend.(haReleaser) // haHostEmpty has checked it is one |
| a.stopFiles(e) |
| a.mu.Lock() |
| f := e.files |
diff --git a/internal/activator/harelease_test.go b/internal/activator/harelease_test.go| index 82939e671..ee52e89c9 100644 |
| --- a/internal/activator/harelease_test.go |
| +++ b/internal/activator/harelease_test.go |
| @@ -814,3 +814,147 @@ func TestHAWakeRequestCounts(t *testing.T) { |
| t.Fatalf("the restored wake's release: %+v", v.Lock.Release) |
| } |
| } |
| + |
| +// I1, the failed wake (final review F1): the tracked invocation is gone, |
| +// replaced by a foreign one (unitproc's observer counts a replacement after |
| +// the stop as the old one's exit), but the host's slice still holds it. No |
| +// marker goes out, the lease stays held, and no other box can acquire; |
| +// the retained wake is retried, and once the slice reads empty the reaper |
| +// writes the unclean marker. |
| +func TestFailedWakeKeepsLeaseWhileSliceHoldsAReplacement(t *testing.T) { |
| + s := haService(t, "shop.example.com") |
| + s.ctl.stopHook = func(string, instancectl.Role) { |
| + s.unit.set(func(u *haUnit) { u.active, u.inv, u.unitPop, u.slicePop = "active", "inv2", true, true }) |
| + } |
| + s.failAfterReplicate() |
| + if _, err := s.wakeForTest(context.Background()); err == nil { |
| + t.Fatal("the wake should fail when its files publisher cannot open") |
| + } |
| + for _, w := range s.lockWriteLog() { |
| + if isMarker(w) { |
| + t.Fatal("a marker went out while the host's slice held a replacement") |
| + } |
| + } |
| + if v := s.lockView(t); v.Lock.Release != nil || !v.HAOn() { |
| + t.Fatalf("the lease is not held: %s", v.Lock.Owner) |
| + } |
| + s.a.mu.Lock() |
| + u := s.a.unprovenWakes[s.rt.Host] |
| + s.a.mu.Unlock() |
| + if u == nil || u.rep == nil { |
| + t.Fatalf("no retained wake with its replica: %+v", u) |
| + } |
| + other := s.restart(t) |
| + lease.SetSelf(hafresh.Self{Ref: "b", IID: "i-b"}) |
| + _, err := other.b.Acquire(context.Background(), other.rt) |
| + lease.SetSelf(hafresh.Self{Ref: "a", IID: "i-a"}) |
| + var held *errLeaseHeld |
| + if !errors.As(err, &held) { |
| + t.Fatalf("another box acquired the host beside its replacement: %v", err) |
| + } |
| + // The reaper, while the slice still holds it: nothing. |
| + s.a.mu.Lock() |
| + s.a.reapUnprovenWakesLocked() |
| + s.a.mu.Unlock() |
| + waitFor(t, "the reaper's try", func() bool { |
| + s.a.mu.Lock() |
| + defer s.a.mu.Unlock() |
| + return !u.busy |
| + }) |
| + if v := s.lockView(t); v.Lock.Release != nil { |
| + t.Fatal("the reaper wrote a marker while the host's slice held a replacement") |
| + } |
| + // The replacement goes: the next try releases. |
| + s.unit.set(func(u *haUnit) { u.active, u.unitPop, u.slicePop = "inactive", false, false }) |
| + s.a.mu.Lock() |
| + s.a.reapUnprovenWakesLocked() |
| + s.a.mu.Unlock() |
| + waitFor(t, "the reaper", func() bool { |
| + s.a.mu.Lock() |
| + defer s.a.mu.Unlock() |
| + return s.a.unprovenWakes[s.rt.Host] == nil |
| + }) |
| + if v := s.lockView(t); v.Lock.Release == nil || v.Lock.Release.Clean { |
| + t.Fatalf("want an unclean marker once the slice is empty, the lock is %+v", v.Lock) |
| + } |
| +} |
| + |
| +// F1 on the start's own failure: root's start fails and leaves no process |
| +// handle, but the host's slice is populated. No marker goes out and the |
| +// lease stays held until the slice reads empty. |
| +func TestFailedStartKeepsLeaseWhileSliceHoldsAProcess(t *testing.T) { |
| + s := haService(t, "shop.example.com") |
| + s.unit.set(func(u *haUnit) { u.sliceHeld = true }) // root's kill leaves the slice populated |
| + start := s.ctl.onStart |
| + s.ctl.onStart = func() { |
| + start() |
| + s.ctl.startErr = errors.New("root: the start failed") |
| + } |
| + _, err := s.wakeForTest(context.Background()) |
| + if err == nil { |
| + t.Fatal("the wake should fail when root's start fails") |
| + } |
| + t.Logf("wake: %v", err) |
| + if v := s.lockView(t); v.Lock.Release != nil || !v.HAOn() { |
| + t.Fatalf("the lease is not held over a populated slice: %+v", v.Lock) |
| + } |
| + s.unit.set(func(u *haUnit) { u.sliceHeld, u.active, u.unitPop, u.slicePop = false, "inactive", false, false }) |
| + waitFor(t, "the reaper", func() bool { |
| + s.a.mu.Lock() |
| + s.a.reapUnprovenWakesLocked() |
| + gone := s.a.unprovenWakes[s.rt.Host] == nil |
| + s.a.mu.Unlock() |
| + return gone |
| + }) |
| + if v := s.lockView(t); v.Lock.Release == nil || v.Lock.Release.Clean { |
| + t.Fatalf("want an unclean marker once the slice is empty, the lock is %+v", v.Lock) |
| + } |
| +} |
| + |
| +// F1, the reaper: a failed wake retained because its stop was unproven. |
| +// Its unit then stops, but a descendant holds the host's slice: the |
| +// reaper's retry writes no marker until the slice reads empty. |
| +func TestReaperKeepsLeaseWhileSlicePopulated(t *testing.T) { |
| + s := haService(t, "shop.example.com") |
| + s.unit.set(func(u *haUnit) { u.stuck = true }) |
| + s.failAfterReplicate() |
| + if _, err := s.wakeForTest(context.Background()); err == nil { |
| + t.Fatal("the wake should fail") |
| + } |
| + s.a.mu.Lock() |
| + u := s.a.unprovenWakes[s.rt.Host] |
| + s.a.mu.Unlock() |
| + if u == nil || u.rep == nil { |
| + t.Fatalf("no retained wake with a replica: %+v", u) |
| + } |
| + s.unit.set(func(u *haUnit) { |
| + u.stuck, u.sliceHeld = false, true |
| + u.active, u.unitPop, u.slicePop = "inactive", false, true |
| + }) |
| + s.a.mu.Lock() |
| + s.a.reapUnprovenWakesLocked() |
| + s.a.mu.Unlock() |
| + waitFor(t, "the reaper's try", func() bool { |
| + s.a.mu.Lock() |
| + defer s.a.mu.Unlock() |
| + return !u.busy |
| + }) |
| + s.a.mu.Lock() |
| + still := s.a.unprovenWakes[s.rt.Host] == u |
| + s.a.mu.Unlock() |
| + if v := s.lockView(t); v.Lock.Release != nil || !v.HAOn() || !still { |
| + t.Fatalf("the reaper released over a populated slice: retained %v, lock %+v", still, v.Lock) |
| + } |
| + s.unit.set(func(u *haUnit) { u.sliceHeld, u.slicePop = false, false }) |
| + s.a.mu.Lock() |
| + s.a.reapUnprovenWakesLocked() |
| + s.a.mu.Unlock() |
| + waitFor(t, "the reaper", func() bool { |
| + s.a.mu.Lock() |
| + defer s.a.mu.Unlock() |
| + return s.a.unprovenWakes[s.rt.Host] == nil |
| + }) |
| + if v := s.lockView(t); v.Lock.Release == nil { |
| + t.Fatal("no marker once the slice is empty") |
| + } |
| +} |
diff --git a/internal/activator/maintenance.go b/internal/activator/maintenance.go| index b43fd0703..db48f399b 100644 |
| --- a/internal/activator/maintenance.go |
| +++ b/internal/activator/maintenance.go |
| @@ -439,6 +439,25 @@ func (a *Service) cleanupFailedWake(ctx context.Context, e *actEntry, rt registr |
| a.mu.Unlock() |
| return |
| } |
| + // An HA host's release goes only over an empty host slice, whatever |
| + // the process's own proof said (haHostEmpty, final review F1): a |
| + // replacement invocation, which the observer counts as the tracked |
| + // one's exit, may still run there. Unproven, the wake is retained as |
| + // an unproven one would be: no marker, the lease held, and the reaper |
| + // retries the whole proof. |
| + if haHeld(lease, w.rep) { |
| + if err := a.haHostEmpty(rt); err != nil { |
| + log.Printf("activator: %s: failed wake: %v; keeping the lease until it is", rt.Host, err) |
| + u := &unprovenWake{rt: rt, gen: w.gen, proc: w.proc, lease: lease, rep: w.rep, build: w.spawnIdentity, |
| + layout: w.launchLayout, legacy: legacy} |
| + w.stopOutcome.uncertain = true |
| + if legacy { |
| + w.stopOutcome.owedBy = u |
| + } |
| + a.retainUnprovenWake(u) |
| + return |
| + } |
| + } |
| // A backend failure may conceal resources beyond the returned handle. |
| // Successful cleanup of that handle does not erase the uncertainty. |
| if w.rep != nil { |
| @@ -450,3 +469,33 @@ func (a *Service) cleanupFailedWake(ctx context.Context, e *actEntry, rt registr |
| } |
| w.stopOutcome.leaseReleased = a.giveBack(ctx, rt.Host, lease) |
| } |
| + |
| +// giveBackAfterStart is a failed wake's release when its start was tried |
| +// and left nothing for cleanupFailedWake to prove (no process, no unproven |
| +// generation, no queued legacy start). A legacy lease goes back as before; |
| +// an HA one only over an empty host slice (haHostEmpty, final review F1), |
| +// and unproven it is retained, the reaper retrying the slice alone. |
| +func (a *Service) giveBackAfterStart(ctx context.Context, rt registry.Route, w *wokenInstance, lease Lease) { |
| + if haHeld(lease, w.rep) { |
| + if err := a.haHostEmpty(rt); err != nil { |
| + log.Printf("activator: %s: failed start: %v; keeping the lease until it is", rt.Host, err) |
| + w.stopOutcome.uncertain = true |
| + a.retainUnprovenWake(&unprovenWake{rt: rt, gen: w.gen, lease: lease, rep: w.rep, build: w.spawnIdentity, |
| + layout: w.launchLayout, sliceOnly: true}) |
| + return |
| + } |
| + } |
| + w.stopOutcome.leaseReleased = a.giveBack(ctx, rt.Host, lease) |
| +} |
| + |
| +// retainUnprovenWake keeps u's lease, and its replica if it has one, until |
| +// the reaper's proof holds; no new wake of the host starts until then. |
| +// Never called with a.mu held. |
| +func (a *Service) retainUnprovenWake(u *unprovenWake) { |
| + a.mu.Lock() |
| + if a.unprovenWakes == nil { |
| + a.unprovenWakes = make(map[string]*unprovenWake) |
| + } |
| + a.unprovenWakes[u.rt.Host] = u |
| + a.mu.Unlock() |
| +} |
diff --git a/internal/activator/opset.go b/internal/activator/opset.go| index 7e1ac5f96..b610d44a4 100644 |
| --- a/internal/activator/opset.go |
| +++ b/internal/activator/opset.go |
| @@ -784,6 +784,10 @@ type unprovenWake struct { |
| // legacy: an aborted start of the host's original run unit whose |
| // queued job may still run (#292, Astra P1). Proven by legacyRunGone. |
| legacy bool |
| + // sliceOnly: an HA wake whose start left nothing else to prove |
| + // (giveBackAfterStart), held only by its host slice. Every retained |
| + // HA wake is proven by haHostEmpty too, whatever else proves it. |
| + sliceOnly bool |
| } |
| // errWakeUnproven refuses a wake while the host's last failed wake is not |
| @@ -886,11 +890,19 @@ func (a *Service) reapUnprovenWake(host string, u *unprovenWake) { |
| } |
| } |
| proven := false |
| - if u.legacy { |
| + switch { |
| + case u.sliceOnly: |
| + proven = true |
| + case u.legacy: |
| proven = a.legacyRunGone(u.rt) == nil |
| - } else { |
| + default: |
| proven = a.failedWakeStopped(u.rt, u.gen, u.proc, u.layout) |
| } |
| + // An HA release goes only over an empty host slice (haHostEmpty, |
| + // final review F1), whatever proved the process gone. |
| + if proven && haHeld(u.lease, u.rep) && a.haHostEmpty(u.rt) != nil { |
| + proven = false |
| + } |
| if !proven { |
| a.mu.Lock() |
| u.busy = false |
diff --git a/internal/sim/regionha/actions_test.go b/internal/sim/regionha/actions_test.go| index c84175d51..6864c7eb0 100644 |
| --- a/internal/sim/regionha/actions_test.go |
| +++ b/internal/sim/regionha/actions_test.go |
| @@ -124,6 +124,11 @@ type wakeOpts struct { |
| SettleFails bool // the owed marker's retry before the acquire fails |
| MarkerFails bool // the unclean release's marker PUT fails |
| + // Straggler: with FailAfterRepl, a unit of the host the failed wake's |
| + // stop missed (a replacement invocation the observer counts as the |
| + // tracked one's exit), exiting in this many ticks. |
| + Straggler int |
| + |
| // CrashBeforeRestore: the agent dies after the acquire's PUT landed |
| // and before the restore read or touched the local copy. The lock is |
| // left as this box's lease, with no release marker. |
| @@ -221,7 +226,7 @@ func (w *world) wake(b *box, h string, o wakeOpts, pre *pending) string { |
| w.event("failed-after-replication") |
| w.tenantWrite(b, h, false) |
| w.sync(b, h, false) |
| - w.closeHA(b, h, o.MarkerFails) |
| + w.closeHA(b, h, o.MarkerFails, o.Straggler) |
| return "failed after replication" |
| } |
| return "served" |
| @@ -497,6 +502,10 @@ type sleepOpts struct { |
| FinalIncomplete bool // the final files publish skips an entry |
| SyncFails bool // the final database sync fails |
| MarkerFails bool // the marker PUT fails |
| + |
| + // Failed: a failed wake's release held by its host slice |
| + // (cleanupFailedWake, the reaper): unclean, at the replica's position. |
| + Failed bool |
| } |
| // sleep is the graceful sleep: the stop (proven for the main unit), then |
| @@ -521,6 +530,14 @@ func (w *world) sleep(b *box, h string, o sleepOpts) { |
| func (w *world) tryRelease(b *box, h string) { |
| e := b.Entries[h] |
| o := *e.Releasing |
| + if o.Failed { |
| + if on("failed-wake-before-slice-empty") && !w.sliceEmpty(b, h) { |
| + return |
| + } |
| + w.sync(b, h, false) |
| + w.releaseUnclean(b, h, e, e.Uploaded, o.MarkerFails) |
| + return |
| + } |
| if on("marker-before-slice-empty") && !w.sliceEmpty(b, h) { |
| w.event("release-held") |
| w.logf("box%d: %s: the host's slice is not proven empty; the release waits", b.ID, h) |
| @@ -643,10 +660,23 @@ func (w *world) releaseUnclean(b *box, h string, e *entry, txid uint64, markerFa |
| // closeHA is a failed wake's Close after replication started: the unit is |
| // stopped, the replicator finalizes (its final sync), then the unclean |
| -// marker at the replica's position. |
| -func (w *world) closeHA(b *box, h string, markerFails bool) { |
| +// marker at the replica's position. straggler is a unit of the host the |
| +// stop missed: while the host's slice holds it, the release is held |
| +// (haHostEmpty, final review F1) with the lease held and renewing, the |
| +// files publisher stopped, and the sweep retries it (tryRelease). |
| +func (w *world) closeHA(b *box, h string, markerFails bool, straggler int) { |
| e := b.Entries[h] |
| w.stopMain(b, h) |
| + if straggler > 0 { |
| + b.Units[h] = append(b.Units[h], &unit{Running: true, Straggler: true, ExitAt: w.step + straggler}) |
| + } |
| + if on("failed-wake-before-slice-empty") && !w.sliceEmpty(b, h) { |
| + e.Pub = nil // stopFiles ran first, and joined it |
| + e.Releasing = &sleepOpts{Failed: true, MarkerFails: markerFails} |
| + w.event("failed-wake-held") |
| + w.logf("box%d: %s: the failed wake's host slice is not proven empty; the lease is kept", b.ID, h) |
| + return |
| + } |
| w.sync(b, h, false) |
| w.releaseUnclean(b, h, e, e.Uploaded, markerFails) |
| } |
| @@ -755,6 +785,9 @@ func (w *world) randomWakeOpts() wakeOpts { |
| o.LateAck = n < 5 |
| o.RestoreFails = n >= 5 && n < 10 |
| o.FailAfterRepl = n >= 10 && n < 15 |
| + if o.FailAfterRepl && w.pct(50) { |
| + o.Straggler = 1 + w.rng.Intn(3) |
| + } |
| o.CrashBeforeRestore = n >= 15 && n < 18 |
| } |
| o.SettleFails = w.fault(30) |
diff --git a/internal/sim/regionha/rules_test.go b/internal/sim/regionha/rules_test.go| index d3fe3f381..2fdd8336e 100644 |
| --- a/internal/sim/regionha/rules_test.go |
| +++ b/internal/sim/regionha/rules_test.go |
| @@ -53,8 +53,9 @@ var allRules = []string{ |
| "first-wake-ignores-leftovers", // an absent lock is created only over an empty prefix |
| // the legacy path, obligations and containment (r3.1, r3.2, r3.3) |
| - "legacy-takes-ha-lock", // takeLegacy answers HALockError for an HA-format lock and writes nothing (r3.1) |
| - "obligation-in-memory-only", // a failed marker PUT is persisted before its error returns (r3.3) |
| - "recover-without-sweep", // sameBoxEmpty needs this agent's startup sweep to have proven every unit stopped (r3.2) |
| - "marker-before-slice-empty", // releaseHAClean holds the release until the host's slice reads empty (r3.2) |
| + "legacy-takes-ha-lock", // takeLegacy answers HALockError for an HA-format lock and writes nothing (r3.1) |
| + "obligation-in-memory-only", // a failed marker PUT is persisted before its error returns (r3.3) |
| + "recover-without-sweep", // sameBoxEmpty needs this agent's startup sweep to have proven every unit stopped (r3.2) |
| + "marker-before-slice-empty", // releaseHAClean holds the release until the host's slice reads empty (r3.2) |
| + "failed-wake-before-slice-empty", // cleanupFailedWake and the reaper hold an HA release until the host's slice reads empty (haHostEmpty, final review F1) |
| } |
diff --git a/internal/sim/regionha/sim_test.go b/internal/sim/regionha/sim_test.go| index 788821c8c..8828d4af9 100644 |
| --- a/internal/sim/regionha/sim_test.go |
| +++ b/internal/sim/regionha/sim_test.go |
| @@ -213,7 +213,7 @@ func TestEveryActionFires(t *testing.T) { |
| "refused-held", "refused-other-expired", "refused-same-box", "refused-leftover-data", |
| "reclassified", "late-ack", "failed-restore", "failed-after-replication", "crash-before-restore", |
| "marker-clean", "marker-unclean", "marker-owed", "obligation-discharged", |
| - "release-held", "ha-lock-on-legacy-path", "hang-resumed", "manifest-committed", |
| + "release-held", "failed-wake-held", "ha-lock-on-legacy-path", "hang-resumed", "manifest-committed", |
| } { |
| if events[e] == 0 { |
| t.Errorf("no %s over 200 seeds", e) |
diff --git a/internal/sim/regionha/witness_test.go b/internal/sim/regionha/witness_test.go| index a18208fa0..795de155a 100644 |
| --- a/internal/sim/regionha/witness_test.go |
| +++ b/internal/sim/regionha/witness_test.go |
| @@ -60,6 +60,8 @@ var witnesses = []witness{ |
| "the agent crashes and its sweep fails; the orphan is between restarts, so the slice reads empty; recovery without the sweep's proof runs beside it once systemd restarts it", wRecoverWithoutSweep}, |
| {"marker-before-slice-empty", "marker-before-slice-empty", "I1", |
| "r3.2: a unit of the host outlives the stop; the release waits for the slice, and a marker before it lets another box run beside the straggler", wStragglerHoldsRelease}, |
| + {"failed-wake-before-slice-empty", "failed-wake-before-slice-empty", "I1", |
| + "final review F1: a wake fails after replication and a replacement invocation outlives its stop; the release waits for the slice, and an unclean marker before it lets another box run beside the replacement", wFailedWakeStragglerHoldsRelease}, |
| } |
| // TestWitnesses is the deterministic half of the mutation evidence. |
| @@ -481,6 +483,20 @@ func wStragglerHoldsRelease(t *testing.T, w *world) { |
| expect(t, "marker-before-slice-empty", w.view(sh).Lock.Release != nil, "the held release never finished: %s", w.lockString(sh)) |
| } |
| +func wFailedWakeStragglerHoldsRelease(t *testing.T, w *world) { |
| + A, B, _ := w.abc() |
| + r := w.req(A, wakeOpts{FailAfterRepl: true, Straggler: 5}) |
| + if r != "failed after replication" { |
| + t.Errorf("setup: %s", r) |
| + } |
| + r = w.req(B, wakeOpts{}) |
| + expect(t, "failed-wake-before-slice-empty", strings.HasPrefix(r, "refused: held"), "B while A's replacement runs: %s", r) |
| + w.advance(6) |
| + v := w.view(sh) |
| + expect(t, "failed-wake-before-slice-empty", v.Lock.Release != nil && !v.Lock.Release.Clean, "the held release never finished: %s", w.lockString(sh)) |
| + w.checkLiveness() |
| +} |
| + |
| // TestKnownGapReusedHostnameLegacyWake documents a known gap, not a rule: |
| // with hostnames reused (#199's never-reuse rule not in force), a box whose |
| // lifetime index still holds a negative entry from the name's earlier |