Commit c4fce84e authored by Valery Sizov's avatar Valery Sizov

Prevent the name collision for retry_due scope

retry_due name is used in replication control flow in ReplicableRegistry
and in legacy Geo logic. It can create a name collisions any time,
in this particular case it was motivated by inability to add Uploads to SSF
with keeping old logic under the feature flag.
parent 2e34d546
...@@ -36,8 +36,8 @@ module Gitlab ...@@ -36,8 +36,8 @@ module Gitlab
scope :checksummed, -> { where.not(verification_checksum: nil) } scope :checksummed, -> { where.not(verification_checksum: nil) }
scope :not_checksummed, -> { where(verification_checksum: nil) } scope :not_checksummed, -> { where(verification_checksum: nil) }
scope :verification_timed_out, -> { verification_started.where("verification_started_at < ?", VERIFICATION_TIMEOUT.ago) } scope :verification_timed_out, -> { verification_started.where("verification_started_at < ?", VERIFICATION_TIMEOUT.ago) }
scope :retry_due, -> { where(verification_arel_table[:verification_retry_at].eq(nil).or(verification_arel_table[:verification_retry_at].lt(Time.current))) } scope :verification_retry_due, -> { where(verification_arel_table[:verification_retry_at].eq(nil).or(verification_arel_table[:verification_retry_at].lt(Time.current))) }
scope :needs_verification, -> { available_verifiables.merge(with_verification_state(:verification_pending).or(with_verification_state(:verification_failed).retry_due)) } scope :needs_verification, -> { available_verifiables.merge(with_verification_state(:verification_pending).or(with_verification_state(:verification_failed).verification_retry_due)) }
scope :needs_reverification, -> { verification_succeeded.where("verified_at < ?", ::Gitlab::Geo.current_node.minimum_reverification_interval.days.ago) } scope :needs_reverification, -> { verification_succeeded.where("verified_at < ?", ::Gitlab::Geo.current_node.minimum_reverification_interval.days.ago) }
# rubocop:enable CodeReuse/ActiveRecord # rubocop:enable CodeReuse/ActiveRecord
...@@ -133,7 +133,7 @@ module Gitlab ...@@ -133,7 +133,7 @@ module Gitlab
# Overridden by Geo::VerifiableRegistry # Overridden by Geo::VerifiableRegistry
def verification_failed_batch_relation(batch_size:) def verification_failed_batch_relation(batch_size:)
verification_failed.retry_due.order(Gitlab::Database.nulls_first_order(:verification_retry_at)).limit(batch_size) # rubocop:disable CodeReuse/ActiveRecord verification_failed.verification_retry_due.order(Gitlab::Database.nulls_first_order(:verification_retry_at)).limit(batch_size) # rubocop:disable CodeReuse/ActiveRecord
end end
# @return [Integer] number of records that need verification # @return [Integer] number of records that need verification
......
...@@ -179,7 +179,7 @@ RSpec.describe Gitlab::Geo::VerificationState do ...@@ -179,7 +179,7 @@ RSpec.describe Gitlab::Geo::VerificationState do
expect(subject.class.needs_verification).to include(subject) expect(subject.class.needs_verification).to include(subject)
end end
it 'includes verification_failed and retry_due' do it 'includes verification_failed and verification_retry_due' do
subject.verification_started subject.verification_started
subject.verification_failed_with_message!('foo') subject.verification_failed_with_message!('foo')
subject.update!(verification_retry_at: 1.minute.ago) subject.update!(verification_retry_at: 1.minute.ago)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment