Skip to content

fix(cluster): lazily start sharded subscribers#2090

Merged
PavelPashov merged 8 commits intoredis:mainfrom
PavelPashov:fix/sharded-pub-sub-lazy-subscribers
Mar 19, 2026
Merged

fix(cluster): lazily start sharded subscribers#2090
PavelPashov merged 8 commits intoredis:mainfrom
PavelPashov:fix/sharded-pub-sub-lazy-subscribers

Conversation

@PavelPashov
Copy link
Copy Markdown
Contributor

@PavelPashov PavelPashov commented Mar 13, 2026

Note

Medium Risk
Changes sharded Pub/Sub connection lifecycle and retry/health logic in ClusterSubscriberGroup/ShardedSubscriber, which can affect subscription reliability and reconnect behavior under topology changes or failures.

Overview
Sharded Pub/Sub subscribers now start lazily and more safely. ClusterSubscriberGroup only starts a ShardedSubscriber when it owns slots with active channel subscriptions (or when redisOptions.lazyConnect is disabled), and can also trigger a start on-demand when a slot is first used.

Subscriber lifecycle/health handling was tightened. ShardedSubscriber now tracks explicit status (idle/starting/connected/...), dedupes concurrent start() calls, prevents revival after stop(), and reset() logic now replaces unhealthy subscribers and avoids resubscribe attempts when the underlying redis instance is missing/ended.

Config + test coverage expanded. The sharded subscriber now inherits ClusterOptions.redisOptions, and tests add coverage for default laziness, honoring redisOptions.lazyConnect, in-flight start behavior, and replace the single sharded pubsub scenario suite with split E2E suites plus a richer fault-injector client (create/delete DB, more action types) and test utilities (waitForAssertion, stricter message stats access).

Written by Cursor Bugbot for commit 5163b9b. This will update automatically on new commits. Configure here.

@PavelPashov PavelPashov force-pushed the fix/sharded-pub-sub-lazy-subscribers branch from e68d706 to 04c5ebe Compare March 13, 2026 16:10
@PavelPashov PavelPashov force-pushed the fix/sharded-pub-sub-lazy-subscribers branch from 5edc7eb to 00b361a Compare March 17, 2026 12:08
@PavelPashov PavelPashov marked this pull request as ready for review March 18, 2026 09:42
@PavelPashov
Copy link
Copy Markdown
Contributor Author

run sharded pub sub tests

@uglide
Copy link
Copy Markdown
Contributor

uglide commented Mar 18, 2026

Testcase Errors Failures Skipped Total
Root Suite 0 0 0 0
Sharded Pub/Sub E2E - Basic 0 0 0 4
Sharded Pub/Sub E2E - Connection Lifecycle 0 0 0 3
Sharded Pub/Sub E2E - Failure Recovery Multiple Subscribers 0 3 0 4
Sharded Pub/Sub E2E - Failure Recovery Single Subscriber 0 2 0 4

---- Details for maintainers

@uglide
Copy link
Copy Markdown
Contributor

uglide commented Mar 18, 2026

Testcase Errors Failures Skipped Total
Root Suite 0 0 0 0
Sharded Pub/Sub E2E - Basic 0 0 0 4
Sharded Pub/Sub E2E - Connection Lifecycle 0 0 0 3
Sharded Pub/Sub E2E - Failure Recovery Multiple Subscribers 0 2 0 4
Sharded Pub/Sub E2E - Failure Recovery Single Subscriber 0 0 0 4

---- Details for maintainers

@PavelPashov PavelPashov force-pushed the fix/sharded-pub-sub-lazy-subscribers branch from 5493ad6 to 465e01a Compare March 18, 2026 13:55
@uglide
Copy link
Copy Markdown
Contributor

uglide commented Mar 19, 2026

Testcase Errors Failures Skipped Total
Root Suite 0 0 0 0
Sharded Pub/Sub E2E - Basic 0 0 0 4
Sharded Pub/Sub E2E - Connection Lifecycle 0 0 0 3
Sharded Pub/Sub E2E - Failure Recovery Multiple Subscribers 0 0 0 4
Sharded Pub/Sub E2E - Failure Recovery Single Subscriber 0 0 0 4

---- Details for maintainers

@redis redis deleted a comment from uglide Mar 19, 2026
@PavelPashov PavelPashov force-pushed the fix/sharded-pub-sub-lazy-subscribers branch from 6d0f77a to b063326 Compare March 19, 2026 14:02
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

@PavelPashov PavelPashov merged commit 4f167bb into redis:main Mar 19, 2026
12 checks passed
@PavelPashov PavelPashov deleted the fix/sharded-pub-sub-lazy-subscribers branch March 19, 2026 15:05
github-actions bot pushed a commit that referenced this pull request Mar 19, 2026
## [5.10.1](v5.10.0...v5.10.1) (2026-03-19)

### Bug Fixes

* **cluster:** lazily start sharded subscribers ([#2090](#2090)) ([4f167bb](4f167bb))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 5.10.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

simong added a commit to simong/ioredis that referenced this pull request Apr 8, 2026
…dying

* origin:
  feat: Implement `TracingChannel` support (redis#2089)
  chore(ci): add custom Redis version to test matrix (redis#2067)
  chore(deps): update and pin production dependencies (redis#2087)
  test: race condition in spub/ssub auto-resubscription test (redis#2092)
  chore(release): 5.10.1 [skip ci]
  fix(cluster): lazily start sharded subscribers (redis#2090)
  chore(release): 5.10.0 [skip ci]
  feat: add hash field expiration commands and tests
  feat: add hexpireat & hexpiretime (redis#2082)
  ci: make Coveralls steps non-blocking in test_with_cov workflow (redis#2083)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants