Fix #93: bound repoBus ring #102
No reviewers
Labels
No labels
actions
bug
cli
duplicate
enhancement
fork
forum
git storage
help wanted
insights
invalid
issues
moderation
oidc
ownership transfer
packages
pr/merge protection rules
projects
pull requests
question
releases
sponsorships
tags
webhooks
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crueber/walhub!102
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/issue-93"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #93:
repoBus.ringin internal/notify/stream.go grew one entry per repo ever published, never evicted.Shape (matches the existing subscriber-cleanup discipline): evict-on-last-subscriber (unsubscribe drops the repo's replay ring alongside its subs entry) + LRU cap of RepoBusMaxRepos (256) retained repos for the publish-with-no-subscribers path. Eviction prefers idle repos, drops replay rings only (live channels never closed; ring rebuilds on next publish). Recency state rides the pre-existing bus mutex — no new locks, no timers, no goroutines.
Behavior nuance (documented in Decisions, docs/features/06_notifications.md): publish-then-subscribe replay is unchanged; a subscriber attaching after a fully idle period, or to an LRU-evicted repo, replays nothing and starts from the live tail. Durable history is the feature timeline/API, never this ring. Worst case now 256 repos x 64 frames.
Regression tests (deterministic, no sleeps): publish-to-N + unsubscribe-all empties the ring; LRU cap evicts oldest-idle first and retains newest; subscribed repos keep replay while idle ones are evicted; all-subscribed overflow keeps live delivery working.
Verification: gofmt/vet clean; go test ./internal/notify/ -race green (incl. -count=10 on TestRepoRing*); coverage 97.3% (gate >=95%).
repoBus.ringnever evicted — unbounded memory #93repoBus.ringnever evicted — unbounded memory #93repoBus.ringnever evicted — unbounded memory #93