Skip to content

Reset connection pool and Rails.cache on reload

Sylvester Chin requested to merge sc1-fix-redis-pool-loading into master

What does this MR do and why?

This MR updates the initializer to reset Redis connection pools and Rails.cache on reload!. This change affects local development only since we do not reload in prod.

The current reload! fails as the Gitlab::Redis::Cache is not reloaded (object_id remains the same), hence @pool in wrapper.rb. However, Gitlab::Redis::MultiStore is reloaded and leads to issues in ClusterUtil when doing an is_a?(MultiStore) check as there are stale references to classes in the Gitlab::Redis namespace.

Screenshots or screen recordings

From the screen-shot, we see that ._client is being called on MultiStore even though it should not happen since that would have triggered the if path.

image

Before After

How to set up and validate locally

On master

  • Browse GitLab-locally
  • Adjust the application controller to add a puts 'something' in an action and save
  • Click a link in GitLab locally. Notice the slow request because of code reloading
  • 💥

Alternatively via console

Rails.cache.redis.with {|c| c.is_a?(Gitlab::Redis::MultiStore)}
=> true
Gitlab::Redis::Cache.with {|c| c.is_a?(Gitlab::Redis::MultiStore)}
=> true

reload!
...

Rails.cache.redis.with {|c| c.is_a?(Gitlab::Redis::MultiStore)}
=> false
Gitlab::Redis::Cache.with {|c| c.is_a?(Gitlab::Redis::MultiStore)}
=> false

On this MR

  • Browse GitLab-locally
  • Adjust the application controller to add a puts 'something' in an action and save
  • Click a link in GitLab locally. Notice the slow request because of code reloading

alternatively via console,

Rails.cache.redis.with {|c| c.is_a?(Gitlab::Redis::MultiStore)}
=> true
Gitlab::Redis::Cache.with {|c| c.is_a?(Gitlab::Redis::MultiStore)}
=> true

reload!
...

Rails.cache.redis.with {|c| c.is_a?(Gitlab::Redis::MultiStore)}
=> true
Gitlab::Redis::Cache.with {|c| c.is_a?(Gitlab::Redis::MultiStore)}
=> true

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sylvester Chin

Merge request reports