diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/gitlab/utils | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/gitlab/utils')
-rw-r--r-- | lib/gitlab/utils/usage_data.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/gitlab/utils/usage_data.rb b/lib/gitlab/utils/usage_data.rb index 5267733d220..0d28a1cd035 100644 --- a/lib/gitlab/utils/usage_data.rb +++ b/lib/gitlab/utils/usage_data.rb @@ -38,6 +38,7 @@ module Gitlab extend self FALLBACK = -1 + DISTRIBUTED_HLL_FALLBACK = -2 def count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil) if batch @@ -59,6 +60,17 @@ module Gitlab FALLBACK end + def estimate_batch_distinct_count(relation, column = nil, batch_size: nil, start: nil, finish: nil) + Gitlab::Database::PostgresHll::BatchDistinctCounter.new(relation, column).estimate_distinct_count(batch_size: batch_size, start: start, finish: finish) + rescue ActiveRecord::StatementInvalid + FALLBACK + # catch all rescue should be removed as a part of feature flag rollout issue + # https://gitlab.com/gitlab-org/gitlab/-/issues/285485 + rescue StandardError => error + Gitlab::ErrorTracking.track_and_raise_for_dev_exception(error) + DISTRIBUTED_HLL_FALLBACK + end + def sum(relation, column, batch_size: nil, start: nil, finish: nil) Gitlab::Database::BatchCount.batch_sum(relation, column, batch_size: batch_size, start: start, finish: finish) rescue ActiveRecord::StatementInvalid |