Database timeout when using scope on Jobs API
Customer is trying to use the jobs API to return scoped results. However, the query appears to timeout on this particular project when using scope
. Interestingly, when you do the same against the gitlab project which certainly has a large number of jobs, it seems to return instantly. Not using a scope returns results fine. https://gitlab.com/api/v4/projects/<project_id>/jobs?per_page=50
https://sentry.gitlab.net/gitlab/gitlabcom/issues/2515397/?referrer=gitlab_plugin
PG::QueryCanceled: ERROR: canceling statement due to statement timeout
active_record/connection_adapters/postgresql_adapter.rb:675:in `exec_params'
@connection.exec_params(sql, type_casted_binds)
active_record/connection_adapters/postgresql_adapter.rb:675:in `block (2 levels) in exec_no_cache'
@connection.exec_params(sql, type_casted_binds)
active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
yield
active_support/concurrency/share_lock.rb:187:in `yield_shares'
yield
active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
@lock.yield_shares(compatible: [:load]) do
...
(184 additional frame(s) were not displayed)
ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR: canceling statement due to statement timeout