Repository navigation
Conversation
SSE sessions for /things?ids=..., /things/<thingId> and the message inbox/outbox routes only emit signals of the requested things, but the streaming session actor did not know these thing IDs. It published every signal the session's subjects may read to the SSE stream, where the route dropped all signals of other things only after post-processing them. Before that, every such signal went through the namespace access check, which was evaluated even when the subscriber was not allowed to read the signal at all, as all checks were computed before combining them. In production, the SSE session summary logged ~94M signals received by SSE sessions within 6 days, of which only 0.17% were delivered; all of them subscribed with "ids" for mostly a single thing. * StartStreaming carries the requested thing IDs, which the SSE routes set and the StreamingSession matches signals against * the streaming session actor applies the checks cheapest first and stops at the first failing one: thing IDs, namespaces, read subjects, namespace access * "sse-received" of the SSE session summary therefore no longer counts signals of other things Assisted-by: Anthropic Claude Opus 5.5 (claude-opus-5-5) Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
This branch has not been deployed
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.
The SSE session summary added in 3.9.9 showed that SSE sessions in production discard almost everything they process: within 6 days, ~94M signals reached SSE sessions and only ~155k (0.17%) were delivered to clients. All of these sessions subscribed with
ids(/api/2/things?ids=...), mostly for a single thing, and none usednamespacesorfilter. A session whose subjects may read most things received ~300 signals/s, i.e. the change events of the whole fleet.The reason: the SSE routes knew the requested thing IDs, but the
StreamingSessionActordid not. It checked every signal the session's subjects may read, including the costly namespace access check, and published it to the SSE stream. Only there didThingsSseRouteBuilder.postprocessdrop the signals of all other things.In addition,
isSessionAllowedToReceiveSignalcomputed all checks before combining them, so the namespace access check also ran for signals the subscriber is not allowed to read.Change
StartStreamingcarries the requested thing IDs. The SSE routes set them for/things?ids=...,/things/<thingId>[/<path>]and the message inbox/outbox routes.StreamingSession.matchesThingIdsmatches a signal's entity ID against them. An empty set matches all signals, so WebSocket sessions are unaffected.StreamingSessionActorapplies the checks cheapest first and stops at the first failing one: thing IDs, namespaces, read subjects, then namespace access. The changed order also benefits WebSocket sessions.Compatibility
sse-receivedof the SSE session summary no longer counts signals of other things, so it is now close tosse-targeted. The documentation inhttpapi-sse.mdis adapted.StartStreamingandStreamingSessionare gateway-internal.release-3.9, so it can be backported to a 3.9.x patch release.Tests
StreamingSessionActorTest: only signals of the requested thing IDs are published, and the namespace access validator is not consulted for signals of other things.StreamingSessionTest: unit tests formatchesThingIds.ThingsSseRouteBuilderTest: a new?ids=a,btest, and the per-thing route tests now check the thing IDs passed toStartStreaming.