Clear the query cache when releasing load balancing hosts
What does this MR do and why?
Another fix for gitlab-com/gl-infra/production#20996 (closed).
Clear the query cache when releasing load balancing hosts
Starting in rails 7.2, ConnectionPool#disable_query_cache! no longer also clears the query cache associated with that connection pool. The load balancer was relying on this behavior.
As a result, query cache state could persist from one request or sidekiq job to another. This would happen if the new request was unlucky enough to get the same load balancer host + puma thread combination as a previous request.
Call clear_query_cache in release_host to correctly clear the cache
when discarding the host.
References
- 2025-12-12: Jobs stuck in pending state with no... (gitlab-com/gl-infra/production#20996 - closed)
- Don't release connection back to pool early in ... (!216881 - merged)
How to set up and validate locally
Run a local gitlab instance with load balancing with and without this change, and observe the proportion of cached vs uncached queries.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.