Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix single Redis connection being used across all threads #18135

Merged
merged 2 commits into from Apr 28, 2022

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Apr 27, 2022

The ideal solution is to check-out Redis from the pool whenever Redis is used and then check it back in, but since that would require rewriting a lot more code, this should help in the meantime...

This enables connection pooling for Rails cache and ensures that each thread gets its own Redis connection.

@Gargron Gargron added the performance Runtime performance label Apr 27, 2022
@Gargron Gargron force-pushed the fix-sidekiq-redis-connection-pool branch 3 times, most recently from 5dcc753 to 9c89329 Compare April 27, 2022 19:50
@Gargron Gargron changed the title Fix single Redis connection being used across all Sidekiq threads Fix single Redis connection being used across all threads Apr 27, 2022
@Gargron Gargron force-pushed the fix-sidekiq-redis-connection-pool branch from 9c89329 to 041955a Compare April 27, 2022 20:29
@Gargron Gargron merged commit 3917353 into main Apr 28, 2022
@Gargron Gargron deleted the fix-sidekiq-redis-connection-pool branch April 28, 2022 15:47
Comment on lines -10 to -14
if namespace
Redis.current = Redis::Namespace.new(namespace, redis: redis_connection)
else
Redis.current = redis_connection
end
Copy link
Contributor

Choose a reason for hiding this comment

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

config/initializers/stoplight.rb is still using Redis.current, so this is likely to cause issues, at least when REDIS_NAMESPACE

kadoshita pushed a commit to kadoshita/mastodon that referenced this pull request May 4, 2022
…8135)

* Fix single Redis connection being used across all Sidekiq threads

* Fix tests
ClearlyClaire pushed a commit to ClearlyClaire/mastodon that referenced this pull request Jul 6, 2023
…8135)

* Fix single Redis connection being used across all Sidekiq threads

* Fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Runtime performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants