Repository navigation
Bound the Link relay's resources, attachments and closures - #488
Merged
Merged
Conversation
The relay held serve peers, attachments and pending AttachmentClosed events without limit, so peers could grow Core's memory without bound. Each now takes a slot at admission, before the Authority is consulted, and a Hello or Open beyond capacity is refused with LimitExceeded and leaves no state: - A resource holds one of 4096 slots from the serve Hello that first names it while the relay holds anything for it: its serve peer, a Hello being decided, an attachment or an unwritten event. Its generation, serve peer and events now live in one record, so the generation map no longer grows with every resource ever served. - An attachment holds one of 16384 slots until it is closed and its AttachmentClosed events are written or discarded, so pending events are bounded by construction. - An attach link holds one of 4096 slots until it ends. RevokeResource now discards the events its revoked serve peer could not read, since its authority is withdrawn and it cannot reconnect; otherwise every destroyed sandbox would keep its slots. An Open of an attachment that closes while the Authority decides fails with LeaseExpired instead of recreating it without a slot.
A serve Hello now takes one of two Hello slots of its resource until it is decided, so later Hellos for a held resource no longer wait on the Authority without limit. An Open takes a stream slot of its attach link before the Authority decides and keeps it until its decision ends, even when the peer resets the stream, and an attach link keeps its slot until every stream and renewal it carried has finished. An Open whose attachment closes while it is decided now fails with LeaseExpired even when another Open has created an attachment under the same ID since.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Core will embed one Link relay (cutover PR2), and every sandbox and agent host will dial it. The relay bounded only per-link streams, pending renewals and queued answers. Serve peers, attachments and pending
AttachmentClosedevents grew without limit.Change (
internal/sandboxlink/relay):LimitExceededand leaves no state.AttachmentClosedevents, so pending events are bounded by construction and never dropped for capacity.Behavior changes:
RevokeResourcediscards events it could not deliver: the authority is withdrawn first, so that generation can never reconnect to read them.LeaseExpiredinstead of recreating it.The wire does not change.
docs/sandbox-link-protocol.md(+ zh) states the limits once and updates admission order, closures, staleness, theLimitExceededrow and Verification.Checks:
go test ./internal/sandboxlink/...(with fuzz seeds),go test -race -count=50 ./internal/sandboxlink/relay/, vet, gofmt, darwin/windows builds,make check-names check-docs check-ci.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.