Skip to content

redis: increase pubsub channel buffer to prevent message drops#4310

Open
mmatczuk wants to merge 1 commit intomainfrom
mmt/redis-fixes-v2
Open

redis: increase pubsub channel buffer to prevent message drops#4310
mmatczuk wants to merge 1 commit intomainfrom
mmt/redis-fixes-v2

Conversation

@mmatczuk
Copy link
Copy Markdown
Contributor

Commits

  • increase pubsub channel buffer to prevent message drops

Jira

  • CON-411

The go-redis pubsub.Channel() defaults to a buffer of 100 messages.
Under concurrent writes (e.g. max_in_flight=10 publishing batches of
100), the buffer overflows and messages are silently dropped since
Redis PubSub is fire-and-forget. Increase buffer to 2000.

Fixes CON-411

select {
case rMsg, open := <-pubsub.Channel():
case rMsg, open := <-pubsub.Channel(redis.WithChannelSize(2000)):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The literal 2000 is a magic number. Per the godev "Magic Numbers" rule, "Name all numeric constants. Every literal number in logic must have a clear meaning through a named constant or variable." Consider extracting this to a package-level constant (e.g. const pubsubChannelBufferSize = 2000) so the rationale (buffer for concurrent writes) is tied to a named symbol.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 20, 2026

Commits
LGTM

Review
Single-line fix adding redis.WithChannelSize(2000) to the pubsub channel call to prevent message drops under concurrent writes.

  1. The literal 2000 should be extracted to a named constant per the godev "Magic Numbers" rule — flagged inline.

This was referenced Apr 20, 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.

1 participant