Skip to content

feat: improve redis dedupe failover handling [poc]#4485

Draft
turip wants to merge 1 commit into
mainfrom
feat/redis-dedupe-failover-support
Draft

feat: improve redis dedupe failover handling [poc]#4485
turip wants to merge 1 commit into
mainfrom
feat/redis-dedupe-failover-support

Conversation

@turip

@turip turip commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Add an explicit sink.dedupeWriteTimeout around the post-persist Redis dedupe write path.
  • Keep dedupe writes retrying until that timeout expires instead of stopping after a fixed attempt count.
  • Recreate the Redis dedupe client/pool after write-path errors that indicate a stale connection or a read-only primary connection.
  • Expose Redis client pool and timeout settings, with a small default pool size of 3.
  • Add focused Redis dedupe tests for reconnect and non-reconnect paths.

Flow-level rationale

The sink flow persists a batch to storage, stores Kafka offsets, and then writes dedupe keys to Redis. At that point the worker is in the consistency-sensitive part of the flow: if Redis dedupe writes fail, future replays can accept duplicate events even though the batch was already persisted.

Before this change, the dedupe write retried with implicit retry defaults. During Redis primary failover, go-redis can remove only the checked-out bad connection while other stale connections remain in the pool. A fixed retry count can therefore be consumed by stale pooled connections before a fresh connection dials and resolves the writable endpoint again.

This change keeps the read-side uniqueness checks fail-fast, but makes the post-persist dedupe write path more resilient. The retry loop is bounded by dedupeWriteTimeout, and reconnect-worthy write errors now swap the Redis client so the next retry starts with a fresh pool and fresh endpoint resolution.

Validation

  • go test ./openmeter/dedupe/redisdedupe ./app/config ./pkg/redis ./openmeter/sink ./app/common

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 59a4d6bb-f550-478d-a121-b906e1115c23

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/redis-dedupe-failover-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@turip turip changed the title feat: improve redis dedupe failover handling feat: improve redis dedupe failover handling [poc] Jun 5, 2026
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