blob: 6a80c631abbc07dab6562b51a9631b65c259a5e4 (
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
|
# frozen_string_literal: true
module Gitlab
module Database
class PostgresAutovacuumActivity < SharedModel
self.table_name = 'postgres_autovacuum_activity'
self.primary_key = 'table_identifier'
scope :wraparound_prevention, -> { where(wraparound_prevention: true) }
def self.for_tables(tables)
Gitlab::Database::LoadBalancing::Session.current.use_primary do
# calling `.to_a` here to execute the query in the primary's scope
# and to avoid having the scope chained and re-executed
#
where('schema = current_schema()').where(table: tables).to_a
end
end
def to_s
"table #{table_identifier} (started: #{vacuum_start})"
end
end
end
end
|