Class: Gitlab::Database::Partitioning::DetachedPartitionDropper
- Inherits:
-
Object
- Object
- Gitlab::Database::Partitioning::DetachedPartitionDropper
- Defined in:
- lib/gitlab/database/partitioning/detached_partition_dropper.rb
Constant Summary collapse
- PROCESSING_DELAY =
1.minute
Instance Method Summary collapse
Instance Method Details
#drop_all_detached_partitions! ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/gitlab/database/partitioning/detached_partition_dropper.rb', line 27 def drop_all_detached_partitions! raise 'This is meant to be used only for test cleanup' unless Rails.env.test? Postgresql::DetachedPartition.all.find_each do |detached_partition| drop_partition(detached_partition) unless partition_attached?(detached_partition.fully_qualified_table_name) end end |
#perform ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/database/partitioning/detached_partition_dropper.rb', line 8 def perform Gitlab::AppLogger.info(message: "Checking for previously detached partitions to drop") Postgresql::DetachedPartition.ready_to_drop.find_each do |detached_partition| if partition_attached?(detached_partition.fully_qualified_table_name) unmark_partition(detached_partition) else drop_partition(detached_partition) end sleep(PROCESSING_DELAY) rescue StandardError => e Gitlab::AppLogger.error(message: "Failed to drop previously detached partition", partition_name: detached_partition.table_name, exception_class: e.class, exception_message: e.) end end |