Error 500 viewing /admin due to counting active users for license
This call is timing out in EE:License:
User.active.excluding_guests.count
https://sentry.gitlab.net/gitlab/gitlabcom/issues/958951/
PG::QueryCanceled: ERROR: canceling statement due to statement timeout
active_record/connection_adapters/postgresql_adapter.rb:611:in `async_exec_params'
@connection.exec_params(sql, type_casted_binds)
active_record/connection_adapters/postgresql_adapter.rb:611: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
...
(200 additional frame(s) were not displayed)
ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR: canceling statement due to statement timeout
: SELECT COUNT(DISTINCT "users"."id") FROM "users" INNER JOIN "members" ON "members"."user_id" = "users"."id" WHERE ("users"."state" IN ('active')) AND (ghost IS NOT TRUE) AND "users"."bot_type" IS NULL AND (members.access_level > 10)
ActionView::Template::Error: PG::QueryCanceled: ERROR: canceling statement due to statement timeout
: SELECT COUNT(DISTINCT "users"."id") FROM "users" INNER JOIN "members" ON "members"."user_id" = "users"."id" WHERE ("users"."state" IN ('active')) AND (ghost IS NOT TRUE) AND "users"."bot_type" IS NULL AND (members.access_level > 10)
ActionView::Template::Error: PG::QueryCanceled: ERROR: canceling statement due to statement timeout
: SELECT COUNT(DISTINCT "users"."id") FROM "users" INNER JOIN "members" ON "members"."user_id" = "users"."id" WHERE ("users"."state" IN ('active')) AND (ghost IS NOT TRUE) AND "users"."bot_type" IS NULL AND (members.access_level > 10)
EXPLAIN ANALYZE:
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=1409088.01..1409088.02 rows=1 width=8) (actual time=46454.311..46454.312 rows=1 loops=1)
-> Merge Join (cost=1.32..1378616.21 rows=12188717 width=4) (actual time=0.016..43440.790 rows=12191476 loops=1)
Merge Cond: (users.id = members.user_id)
-> Index Scan using users_pkey on users (cost=0.43..494021.75 rows=4382501 width=4) (actual time=0.007..10185.784 rows=4383060 loops=1)
Filter: ((ghost IS NOT TRUE) AND (bot_type IS NULL) AND ((state)::text = 'active'::text))
Rows Removed by Filter: 57381
-> Index Scan using index_members_on_user_id on members (cost=0.43..763200.68 rows=12349341 width=4) (actual time=0.007..29638.193 rows=12251605 loops=1)
Filter: (access_level > 10)
Rows Removed by Filter: 139378
Planning time: 4.093 ms
Execution time: 46454.419 ms
(11 rows)
(END)
Edited by Stan Hu