diff --git a/doc/development/query_count_limits.md b/doc/development/query_count_limits.md index b3ecaf30d8a06d1709fb9ab05c03286bcb328f7f..b58933263cc7b8cf888aa9ff390a44d5e0704531 100644 --- a/doc/development/query_count_limits.md +++ b/doc/development/query_count_limits.md @@ -9,30 +9,30 @@ When a test fails because it executes more than 100 SQL queries there are two solutions to this problem: - Reduce the number of SQL queries that are executed. -- Whitelist the controller or API endpoint. +- Allowlist the controller or API endpoint. -You should only resort to whitelisting when an existing controller or endpoint +You should only resort to allowlisting when an existing controller or endpoint is to blame as in this case reducing the number of SQL queries can take a lot of effort. Newly added controllers and endpoints are not allowed to execute more than 100 SQL queries and no exceptions will be made for this rule. _If_ a large number of SQL queries is necessary to perform certain work it's best to have this work performed by Sidekiq instead of doing this directly in a web request. -## Whitelisting +## Allowlisting -In the event that you _have_ to whitelist a controller you'll first need to +In the event that you _have_ to allowlist a controller you'll first need to create an issue. This issue should (preferably in the title) mention the controller or endpoint and include the appropriate labels (`database`, `performance`, and at least a team specific label such as `Discussion`). -Once the issue has been created you can whitelist the code in question. For +Once the issue has been created you can allowlist the code in question. For Rails controllers it's best to create a `before_action` hook that runs as early as possible. The called method in turn should call -`Gitlab::QueryLimiting.whitelist('issue URL here')`. For example: +`Gitlab::QueryLimiting.allowlist('issue URL here')`. For example: ```ruby class MyController < ApplicationController - before_action :whitelist_query_limiting, only: [:show] + before_action :allowlist_query_limiting, only: [:show] def index # ... @@ -42,8 +42,8 @@ class MyController < ApplicationController # ... end - def whitelist_query_limiting - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/...') + def allowlist_query_limiting + Gitlab::QueryLimiting.allowlist('https://gitlab.com/gitlab-org/...') end end ``` @@ -52,12 +52,12 @@ By using a `before_action` you don't have to modify the controller method in question, reducing the likelihood of merge conflicts. For Grape API endpoints there unfortunately is not a reliable way of running a -hook before a specific endpoint. This means that you have to add the whitelist +hook before a specific endpoint. This means that you have to add the allowlist call directly into the endpoint like so: ```ruby get '/projects/:id/foo' do - Gitlab::QueryLimiting.whitelist('...') + Gitlab::QueryLimiting.allowlist('...') # ... end