diff --git a/app/workers/background_migration_worker.rb b/app/workers/background_migration_worker.rb index 17aa43856c01311ef321c3e4caae0567d1b790e4..70c4ad537264b4d89b47a223b5be10ae4f8d6e75 100644 --- a/app/workers/background_migration_worker.rb +++ b/app/workers/background_migration_worker.rb @@ -59,8 +59,10 @@ def perform_and_ttl(class_name, attempts_left) database_unhealthy_counter.increment if lease_obtained && !healthy_db - # If we've tried several times to get a lease with a healthy DB without success, just give up. - # Otherwise we could end up in an infinite rescheduling loop. + # When the DB is unhealthy or the lease can't be obtained after several tries, + # then give up on the job and log a warning. Otherwise we could end up in + # an infinite rescheduling loop. Jobs can be tracked in the database with the + # use of Gitlab::Database::BackgroundMigrationJob if !perform && attempts_left < 0 msg = if !lease_obtained 'Job could not get an exclusive lease after several tries. Giving up.'