Skip to content

feat(cluster): route sharded Pub/Sub by slot - #73

Open
mcollina wants to merge 1 commit into
mainfrom
fix/p1-13-sharded-pubsub
Open

mcollina wants to merge 1 commit into
mainfrom
fix/p1-13-sharded-pubsub

Conversation

@mcollina

Copy link
Copy Markdown
Collaborator

Summary

  • route SSUBSCRIBE and SUNSUBSCRIBE to the primary that owns the channel slot
  • keep independent lazy sharded subscriber connections per active primary
  • preserve subscriptions across topology refreshes, MOVED responses, reconnects, and slot migration
  • support client-wide subscription counts and zero-argument SUNSUBSCRIBE
  • clean up stale subscriptions, connections, listeners, retries, and timers
  • keep classic Pub/Sub on the existing cluster subscriber

Closes #13.

Integration coverage

Adds a dedicated test-valkey-cluster GitHub Actions job. It starts three Valkey primaries and three replicas from the pinned valkey/valkey:8.0.9 image, then verifies real SSUBSCRIBE/SPUBLISH delivery for channels owned by different primaries.

The same test runs locally with:

npm run test:integration:valkey-cluster

Validation

  • npm run build
  • npm run test:tsd
  • targeted sharded Pub/Sub tests: 10 passing
  • Docker Valkey Cluster integration: passing
  • npm run lint: no errors; 12 pre-existing warnings
  • full JS suite: 425 passing; the existing localhost IPv6 assertions fail on this IPv4-resolving host and cause two cascading test failures

Upstream attribution

ClusterSubscriberGroup and ShardedSubscriber adapt work from redis/ioredis PRs #1956, #2013, #2043, #2060, and #2090.

The implementation commit includes Co-authored-by attribution for David Maier, Tihomir Krasimirov Mateev, Pavel Pashov, and Hristo Temelski.

Adapt the sharded subscriber-group architecture and lifecycle work from redis/ioredis PRs #1956, #2013, #2043, #2060, and #2090.

Co-authored-by: David Maier <60782329+dmaier-redislabs@users.noreply.github.com>

Co-authored-by: Tihomir Krasimirov Mateev <tihomir.mateev@redis.com>

Co-authored-by: Pavel Pashov <60297174+PavelPashov@users.noreply.github.com>

Co-authored-by: Hristo Temelski <hristo.temelski@redis.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollina force-pushed the fix/p1-13-sharded-pubsub branch from 26e269e to e840c90 Compare July 14, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build Sharded PubSub command routing based on channel/slot ownership

1 participant