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

autovacuum_active_on_table.rb « indicators « health_status « background_migration « database « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 48e12609a135b1f30e9fe432cf70a1b2394798b9 (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
40
41
# frozen_string_literal: true

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

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

              autovacuum_active_on = active_autovacuums_for(context.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 :context

            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
end