`Ci::JobArtifact#update_project_statistics` fails because of statement timeout
Problem to solve
ActiveRecord::StatementInvalid: PG::QueryCanceled: ERROR: canceling statement due to statement timeout
https://sentry.gitlab.net/gitlab/gitlabcom/issues/476076/
PG::QueryCanceled: ERROR: canceling statement due to statement timeout
CONTEXT: while updating tuple (47177,46) in relation "project_statistics"
peek/views/pg.rb:17:in `async_exec'
super(*args)
peek/views/pg.rb:17:in `async_exec'
super(*args)
active_record/connection_adapters/postgresql_adapter.rb:592:in `block in exec_no_cache'
log(sql, name, binds) { @connection.async_exec(sql, []) }
active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
:binds => binds) { yield }
active_support/notifications/instrumenter.rb:20:in `instrument'
yield payload
...
(250 additional frame(s) were not displayed)
ActiveRecord::StatementInvalid: PG::QueryCanceled: ERROR: canceling statement due to statement timeout
CONTEXT: while updating tuple (47177,46) in relation "project_statistics"
: UPDATE "project_statistics" SET build_artifacts_size = COALESCE(build_artifacts_size, 0) + (12566722), storage_size = COALESCE(storage_size, 0) + (12566722) WHERE "project_statistics"."project_id" = 2648174
ActiveRecord::StatementInvalid: PG::QueryCanceled: ERROR: canceling statement due to statement timeout
CONTEXT: while updating tuple (47177,46) in relation "project_statistics"
: UPDATE "project_statistics" SET build_artifacts_size = COALESCE(build_artifacts_size, 0) + (12566722), storage_size = COALESCE(storage_size, 0) + (12566722) WHERE "project_statistics"."project_id" = 2648174
Proposed solution
Update build_artifacts_size to use efficient counters. This will be done in #23327 (closed).
Edited by Thao Yeager