Skip to content

test(scenario): tolerate at-least-once duplicate delivery during sharded pub/sub handoff#3345

Open
kiryazovi-redis wants to merge 1 commit into
redis:masterfrom
kiryazovi-redis:fix/scho-oss-pubsub-migrate-duplicates
Open

test(scenario): tolerate at-least-once duplicate delivery during sharded pub/sub handoff#3345
kiryazovi-redis wants to merge 1 commit into
redis:masterfrom
kiryazovi-redis:fix/scho-oss-pubsub-migrate-duplicates

Conversation

@kiryazovi-redis

@kiryazovi-redis kiryazovi-redis commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The OSS sharded pub/sub smart-client-handoff scenario asserted at-most-once
delivery (received <= sent) for the window in which slots are being migrated.
Sharded pub/sub delivery across a slot migration / connection handoff is
at-least-once: while the client re-establishes its shard subscriptions on the
new owner, a small number of messages can be delivered more than once. That is
expected, correct behaviour, so the strict received <= sent assertion made the
test fail intermittently.

What changed

  • During the migration window, assert that delivery continues (messages keep
    being received on every channel) instead of asserting received <= sent.
  • Keep the strict correctness assertions for the steady state after the
    migration completes, so genuine message loss/duplication outside the handoff
    window is still caught.

Only test code is touched; no client/runtime behaviour changes.

Test plan

  • Sharded pub/sub scenario suite against a multi-shard cluster, exercising the
    migrate/handoff path.

Prepared with AI assistance and reviewed under my account.


Note

Low Risk
Test-only assertion and comment updates; no production code paths affected.

Overview
Fixes flaky OSS smart-client handoff E2E tests that treated at-least-once pub/sub delivery during slot migration as a failure.

While publishing through a migrate/handoff, assertions no longer require received <= sent (which breaks when the client briefly subscribes on the new shard owner before tearing down the old connection and duplicates are expected). They now only check that each channel keeps receiving messages during the migration window, with inline comments documenting that behavior.

Strict received === sent checks after migration (post-stabilize publish burst) are unchanged, so real loss or bad duplication outside the handoff window is still caught. Test-only change in smart-client-handoffs-oss.e2e.ts; no client/runtime changes.

Reviewed by Cursor Bugbot for commit 0757f68. Bugbot is set up for automated code reviews on this repo. Configure here.

…ate handoff

The OSS smart-client-handoff scenario subscribes the new pub/sub node before
destroying the old one, so a broadcast message can be delivered by both
connections during the overlap window (intentional at-least-once). The
during-migrate assertion `received <= sent` encoded an at-most-once invariant
that this handoff deliberately does not provide, producing spurious
`received (N) should be <= sent (M)` failures. Assert instead that delivery
continued through the handoff; the strict, loss-free `received === sent` check
after migration is unchanged.
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.

2 participants