Welcome to mirror list, hosted at ThFree Co, Russian Federation.

autovacuum_active_on_table.rb « indicators « health_status « database « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6bf2bbf0c707df8a5c72e0070063fc845adb3d28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

module Gitlab
  module Database
    module HealthStatus
      module Indicators
        class AutovacuumActiveOnTable
          def initialize(context)
            @tables = context.tables
          end

          def evaluate
            return Signals::NotAvailable.new(self.class, reason: 'indicator disabled') unless enabled?

            autovacuum_active_on = active_autovacuums_for(tables)

            if autovacuum_active_on.empty?
              Signals::Normal.new(self.class, reason: 'no autovacuum running on any relevant tables')
            else
              Signals::Stop.new(self.class, reason: "autovacuum running on: #{autovacuum_active_on.join(', ')}")
            end
          end

          private

          attr_reader :tables

          def enabled?
            Feature.enabled?(:batched_migrations_health_status_autovacuum, type: :ops)
          end

          def active_autovacuums_for(tables)
            Gitlab::Database::PostgresAutovacuumActivity.for_tables(tables)
          end
        end
      end
    end
  end
end