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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/database/reindexing/reindex_action.rb')
-rw-r--r--lib/gitlab/database/reindexing/reindex_action.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/gitlab/database/reindexing/reindex_action.rb b/lib/gitlab/database/reindexing/reindex_action.rb
index 8c59cffe5fb..7e58201889f 100644
--- a/lib/gitlab/database/reindexing/reindex_action.rb
+++ b/lib/gitlab/database/reindexing/reindex_action.rb
@@ -14,27 +14,23 @@ module Gitlab
scope :recent, -> { where(state: :finished).where('action_end > ?', Time.zone.now - RECENT_THRESHOLD) }
- def self.keep_track_of(index, &block)
- action = create!(
+ def self.create_for(index)
+ create!(
index_identifier: index.identifier,
action_start: Time.zone.now,
ondisk_size_bytes_start: index.ondisk_size_bytes,
bloat_estimate_bytes_start: index.bloat_size
)
+ end
- yield
-
- action.state = :finished
- rescue
- action.state = :failed
- raise
- ensure
+ def finish
index.reload # rubocop:disable Cop/ActiveRecordAssociationReload
- action.action_end = Time.zone.now
- action.ondisk_size_bytes_end = index.ondisk_size_bytes
+ self.state = :finished unless failed?
+ self.action_end = Time.zone.now
+ self.ondisk_size_bytes_end = index.ondisk_size_bytes
- action.save!
+ save!
end
end
end