mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
3d53563ca990e8808b146944948bc17626872bbc
Addresses three architect findings on the first S2 drop:
1. High: Unsubscribe(vid, rid) was key-wide — one Bridge exiting
silently closed channels for all other peers on the same
(VolumeID, ReplicaID). Replaced with per-subscription cancel:
Subscribe now returns (ch, cancel func). Each cancel closes only
its own subscription. Publisher owns a nextSubID counter and
tracks subscriptions as []*subscription per key. Cancel is
idempotent and safe against concurrent Run-exit teardown via a
"whoever finds it closes it" protocol.
Regression test: TestPublisher_IndependentUnsubscribe_OtherPeersUnaffected.
2. High: silent drop on full subscriber buffer could leave the
adapter on stale authority truth until an unrelated later ask
happened — unacceptable for an authority route. Per-subscription
channels are capacity 1 with overwrite-latest semantics: on full,
the publisher drains the stale pending value and retries send,
so the subscriber always reads the LATEST authoritative state
next. Intermediate states may be coalesced (correct for authority
truth; the engine cares about current identity, not interstitial
history).
Regression test: TestPublisher_DeliveryConvergesToLatestOnSlowConsumer.
3. Medium: the non-forgeability structural test was a regex-based
grep over core/ only, and caught only composite-literal Epoch
assignments. Rewritten as an AST-based walker that (a) covers
the whole repo (cmd/ and future production packages included,
not just core/) and (b) catches both composite-literal mints
with non-zero Epoch/EndpointVersion AND local variable
declarations of type AssignmentInfo — the classic bypass shape
for deferred mutation: `var x AssignmentInfo; x.Epoch = input`.
The stronger check surfaced three pre-existing hidden operator
paths in cmd/sparrow/main.go that minted AssignmentInfo with
hard-coded epochs 1/2/3 directly. All three demo sites are now
routed through a shared authority.Publisher: healthy demo issues
IntentBind, catch_up and rebuild demos issue IntentReassign.
No sparrow demo code constructs AssignmentInfo directly anymore.
Other:
* Run now closes every live subscription channel on exit, so
Bridges observe end-of-stream cleanly. Tested by
TestPublisher_RunClosesLiveSubscriptionsOnExit.
* Publisher.apply() releases the publisher lock before fan-out,
preventing a slow consumer from stalling the authoring loop.
Docs updated:
* docs/p14-s2-design.md — Publication API now documents
per-subscription cancel, removes the stale Unsubscribe(vid,rid)
verb, adds the "lossless for current fact" delivery semantic.
* docs/p14-s2-closure.md — test list updated (20 tests), Changed
section records the sparrow migration.
No changes to engine, adapter, transport, ops, storage.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Languages
Go
84.6%
Rust
7.8%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%