Redis session store is not using a connection pool
While working on the ActionCable stuff, I had to dig into the redis-store
gem and how we use it. I found out that we're actually not using a connection pool for reading / writing session data.
When we configure the session store in https://gitlab.com/gitlab-org/gitlab/blob/9b33e3d36fcd46072b9fe83f1121fb0fd87c0fd7/config/initializers/session_store.rb#L21-29, we only pass in the Redis server options and we don't pass the pool
or pool_size
option which the gem supports (https://github.com/redis-store/redis-rack/blob/94d4942bb6106c1baf89d0d8d396d1101be584a3/lib/redis/rack/connection.rb#L27)
Since we're running Puma, we may have some contention on this single Redis connection?
Something like this should probably fix it:
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index da24881885e..6e5ac0877e2 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -17,6 +17,7 @@ cookie_key = if Rails.env.development?
sessions_config = Gitlab::Redis::SharedState.params
sessions_config[:namespace] = Gitlab::Redis::SharedState::SESSION_NAMESPACE
+sessions_config[:pool_size] = Gitlab::Redis::SharedState.pool_size
Gitlab::Application.config.session_store(
:redis_store, # Using the cookie_store would enable session replay attacks.
Ideally, we'd want this to share the same pool with Gitlab::Redis::SharedState
like we did for the cache store in bf51dab8 but this is tricky because this is actually a pool of Redis::Store
clients (which also handle serialization of Ruby objects) and not a regular pool of Redis
clients.