blob: c517cf94c6edb15204551c5da6acc18924c5b0b3 (
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
42
43
|
# frozen_string_literal: true
module Gitlab
module Database
module Partitioning
def self.register_models(models)
registered_models.merge(models)
end
def self.registered_models
@registered_models ||= Set.new
end
def self.sync_partitions(models_to_sync = registered_models)
Gitlab::AppLogger.info(message: 'Syncing dynamic postgres partitions')
Gitlab::Database::EachDatabase.each_model_connection(models_to_sync) do |model|
PartitionManager.new(model).sync_partitions
end
Gitlab::AppLogger.info(message: 'Finished sync of dynamic postgres partitions')
end
def self.report_metrics(models_to_monitor = registered_models)
partition_monitoring = PartitionMonitoring.new
Gitlab::Database::EachDatabase.each_model_connection(models_to_monitor) do |model|
partition_monitoring.report_metrics_for_model(model)
end
end
def self.drop_detached_partitions
Gitlab::AppLogger.info(message: 'Dropping detached postgres partitions')
Gitlab::Database::EachDatabase.each_database_connection do
DetachedPartitionDropper.new.perform
end
Gitlab::AppLogger.info(message: 'Finished dropping detached postgres partitions')
end
end
end
end
|