carlos / platform Public

activator: HA wake request counts leave out litestream's level listings

TestHAWakeRequestCounts and TestLargeManifestReleaseThenKeep counted every
request the fixture served between a wake's start and its return. The wake
opens the litestream store, which starts its compaction and snapshot
monitors in goroutines of their own, and each lists its level once at
start ("LIST <host>/0009/", "/0001/" ...). On a loaded runner those
listings land before the wake returns, and the budget failed with them
appended (CI 2026-10-26/27 on main and four branches).

The windows now drop LISTs of the replica's level directories, as
sleepRequests already filters a stop's requests to the lock and the files:
they are replication's requests, not the wake's.

Under load (2 cores shared with 4 busy loops, nice 19, -cpu 1,2): before
3 failures in 120 runs, after 0 in 200.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 3e0325a3f300b990d5667a53c422e9ec3c6fb704 parent 90d36e6
2 files changed, +36 −2
  • internal/activator/harelease_keep_test.go +1 −1
  • internal/activator/harelease_test.go +35 −1
diff --git a/internal/activator/harelease_keep_test.go b/internal/activator/harelease_keep_test.go
index 400cc742b..8788141a9 100644
--- a/internal/activator/harelease_keep_test.go
+++ b/internal/activator/harelease_keep_test.go
@@ -36,7 +36,7 @@ func TestLargeManifestReleaseThenKeep(t *testing.T) {
if _, err := s.wakeForTest(context.Background()); err != nil {
t.Fatal(err)
}
- reqs := s.fx.Requests()[n:]
+ reqs := s.wakePathRequests(s.fx.Requests()[n:])
if restoreCalls(s.b) != 0 || strings.Join(reqs, ",") != "GET "+lock+",PUT "+lock {
t.Fatalf("a kept wake with a large manifest made %v (%d restores)", reqs, restoreCalls(s.b))
}
diff --git a/internal/activator/harelease_test.go b/internal/activator/harelease_test.go
index 2d96a625b..750ea14c1 100644
--- a/internal/activator/harelease_test.go
+++ b/internal/activator/harelease_test.go
@@ -837,7 +837,7 @@ func TestHAWakeRequestCounts(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- return e, s.fx.Requests()[n:]
+ return e, s.wakePathRequests(s.fx.Requests()[n:])
}
e, reqs := wake()
// A first wake: the lock's three, then the launch's publish of its
@@ -871,6 +871,40 @@ func TestHAWakeRequestCounts(t *testing.T) {
}
}
+// wakePathRequests is reqs without the replica's level listings
+// ("LIST <host>/0001/" ... "LIST <host>/0009/"). Those are litestream's
+// compaction and snapshot monitors, which the store starts in goroutines
+// of their own when the wake opens it: they list their level once at
+// start, whenever they are scheduled, so on a loaded runner they land
+// before the wake returns and otherwise after it (CI, 2026-10-26 and
+// 2026-10-27). They are replication's requests, not the wake's, and
+// counting them made the wake's budget depend on the scheduler.
+func (s *haSvc) wakePathRequests(reqs []string) []string {
+ prefix := s.b.Cfg.hibernatePrefix(s.rt.Host) + "/"
+ var out []string
+ for _, r := range reqs {
+ if level, ok := strings.CutPrefix(r, "LIST "+prefix); ok && isReplicaLevelDir(level) {
+ continue
+ }
+ out = append(out, r)
+ }
+ return out
+}
+
+// isReplicaLevelDir reports whether rel is one of litestream's level
+// directories as a listing names it: four digits and a slash.
+func isReplicaLevelDir(rel string) bool {
+ if len(rel) != 5 || rel[4] != '/' {
+ return false
+ }
+ for _, c := range rel[:4] {
+ if c < '0' || c > '9' {
+ return false
+ }
+ }
+ return true
+}
+
// 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