Repository navigation
Conversation
… limit push data When SharedSubscriptionConnection isn't set, decide per server from the interactive HELLO: share with Redis 9+ (redis/redis#16390), Garnet, and Dragonfly v1.15+; keep a dedicated subscription connection everywhere else (Redis <= 8.x and unstable builds, Valkey, KeyDB, Redict) and for proxied deployments (AMR, Redis Cloud, Enterprise). A server that stops qualifying on reconnect falls back to dedicated for good. Also: detect Dragonfly v1.0 (dfly_version), and only take HELLO's version from the interactive connection, so Valkey 7.2 (server: redis, its own version) can't overwrite INFO's redis_version from a subscription reconnect.
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.
#3264 moved RESP3 pub/sub back onto a dedicated connection by default (#3263): Redis applies the
pubsuboutput-buffer limits to everything sent to a subscribed client, replies included, so a large reply on a shared connection gets it killed. redis/redis#16390 changes that for RESP3 clients (only unsent push data counts againstpubsub; replies count againstnormal), and we can assume it ships in the next major. This gets ahead of it: whenSharedSubscriptionConnectionisn't set, the decision is made per server from the interactive connection'sHELLO.What shares by default
server: redis, no vendor field)255.255.255)pubsubhard limitHELLOdescribes the database behind the proxy, not the proxy's limitsAn explicit
sharedSubscriptionConnection=true|false(or a provider defaulting it totrue) still wins, and RESP2 never shares. There's no public API change: the existing option just gains a meaningful "unset".How
ConfigurationOptions.SubscriptionSharing(internal) resolves the option to Always / Never / Auto. Proxied providers set an internalAllowAutomaticSubscriptionSharing => false, so they resolve unset to Never.SharesSubscriptionConnection()behaves like Always until the handshake, so nothing opens a dedicated connection that turns out to be unnecessary. TheHELLOprocessor then records the verdict (SubscriptionSharingPolicy) before anything queued behind the handshake is written.Variant detection
Along the way I checked that every variant is detected, against real servers for both protocols, and fixed two gaps:
dfly_version(notdragonfly_version) and has noHELLO, so it was detected as plain Redis.server: redisinHELLObut reports its own version (7.2.16, where INFO hasredis_version:7.2.4).HELLO's version is now only taken from the interactive connection, where INFO follows and has the final say. Before, a subscription connection'sHELLOcould land later and overwrite it (Detected server version is non-deterministic on Valkey since 3.4.0 #3278 again, for the one Valkey line that saysredis).ProductVariantUnitTestsnow covers Dragonfly (both spellings), Redict, KeyDB and Valkey 7.2'sHELLOshape. That includes a deterministic subscription-reconnect check, which fails without the fix.Testing
SubscriptionSharingUnitTests: the policy table, mode resolution, and connection shape per server shape (in-process server with fakedHELLOreplies). Also: RESP2 downgrade, a subscription queued before the handshake landing on the right connection, the fallback-and-stay-dedicated latch, and the proxied-provider opt-out.PubSubOutputBufferTestsgains a default-setting variant.ClientKill,ConnectUsesSingleSocketandDedicatedThreadsTestsnow set the option explicitly rather than relying on "unset means dedicated", which stops being true on Redis 9.main.redis/redis#16390 itself is not merged, and I haven't run a build of it, so the Redis 9 row is an assumption about what ships. Until a 9.x exists, nothing real qualifies on that row.
Before merging
Don't merge this until redis/redis#16390 is merged and the Redis 9 assumption has been checked against it:
pubsubhard limit, the server reports a version this policy treats as qualifying, andPubSubOutputBufferTests(including the default-setting variant) passes against itRelease note
Checklist