Fix quota reset before next release
Today we hit problem of 1th of month where quota was not reset due to SQL timeout.
The problem is with this query: https://gitlab.com/gitlab-org/gitlab-ee/blob/master/app/workers/clear_shared_runners_minutes_worker.rb#L10.
We have:
> ProjectStatistics.count
=> 2385330
This leads to SQL query timeout. Thus we do not reset quotas. And process even that retried do fail.
The simplest fix is to change the offending code:
ProjectStatistics.where('shared_runners_seconds > 0').
update_all(shared_runners_seconds: 0,
shared_runners_seconds_last_reset: Time.now)
NamespaceStatistics.where('shared_runners_seconds > 0').
update_all(shared_runners_seconds: 0,
shared_runners_seconds_last_reset: Time.now)
But this, we limit data set to a reasonable amount and we do not hit the timeout. However, this is still not ideal, as we should reduce the number of updates at a single time to some amount, like 1k-10k.