feat(realtime): fix head-of-line blocking in realtime fanout with bounded concurrency and proactive slow-consumer quarantine (#379) - #393
Draft
s6pa1rta3n-lab wants to merge 1 commit into
Conversation
…low-consumer policy
5 tasks
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.
Overview
Resolves #379.
This pull request addresses the head-of-line blocking vulnerability in
fanout_messageby decoupling message delivery from overflow and eviction handling, enforcing bounded concurrency with per-connection isolation, and introducing a proactive slow-consumer detection and quarantine policy inpolicy.rs.Key Changes
Bounded-Concurrency Fanout (
backend/src/realtime/fanout.rs):buffer_unordered(configurable concurrency limit, default 64).handle_overflow(&id).awaitexecution from the hot fanout path.Proactive Slow-Consumer Detection & Quarantine (
backend/src/realtime/policy.rs):ConnectionPolicyTrackerwith queue depth trend analysis (Stable,Growing,Draining,Stalled).ConnectionHealthStatelifecycle transitions:Healthy -> Degraded -> Quarantined -> Evicted.Isolated Connection Accounting (
backend/src/realtime/connection.rs):Connectionwith atomic queue depth tracking and non-blocking policy evaluation.ConnectionReceiverfor automated message consumption accounting, drain rate metrics, and queue depth synchronization.Comprehensive Test Suite & Benchmarks (
backend/tests/slow_consumer_test.rs):ConnectionRegistry::addinterface.Acceptance Criteria Checklist
policy.rsgains a documented, tested slow-consumer detection policy beyond "channel send failed."cargo testsuite stays green.Verification
cargo test --lib: 36 unit tests passed.cargo test --tests: All integration test suites passed (connected_trace_test,discrepancy_alert_test,double_replay_test,dual_network_ingestion_test,mixed_version_replay_test,slow_consumer_test).contracts/passed.Payout Routing
0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC