Prefer `Gitlab::QueryLimiting.disable!` of `allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(X)`
Problem
Using allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(X) in specs over Gitlab::QueryLimiting.disable!(issue) in production has the following downsides:
- The threshold is tweaked per spec and not per controller/worker/service
- Follow-up issues are not always linked
See https://docs.gitlab.com/ee/development/database/query_count_limits.html
The only upside of this approach is that a specific threshold is defined instead of disable the query limit completely.
This means that Gitlab::QueryLimiting.disable!(issue) should provide a way of defining a higher, specific threshold. See #468137
Proposed solution
Ban the use of allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(X) and suggest to use Gitlab::QueryLimiting.disable!.
Edited by Peter Leitzen