Commit 68891961 authored by Sean Carroll's avatar Sean Carroll

Backport EE issue 12996

parent 937b2027
......@@ -460,8 +460,8 @@ module Ci
canceled? && auto_canceled_by_id?
end
def cancel_running
retry_optimistic_lock(cancelable_statuses) do |cancelable|
def cancel_running(retries: nil)
retry_optimistic_lock(cancelable_statuses, retries) do |cancelable|
cancelable.find_each do |job|
yield(job) if block_given?
job.cancel
......@@ -469,10 +469,10 @@ module Ci
end
end
def auto_cancel_running(pipeline)
def auto_cancel_running(pipeline, retries: nil)
update(auto_canceled_by: pipeline)
cancel_running do |job|
cancel_running(retries: retries) do |job|
job.auto_canceled_by = pipeline
end
end
......
......@@ -4,7 +4,8 @@ module Gitlab
module OptimisticLocking
module_function
def retry_lock(subject, retries = 100, &block)
def retry_lock(subject, retries = nil, &block)
retries ||= 100
# TODO(Observability): We should be recording details of the number of retries and the duration of the total execution here
ActiveRecord::Base.transaction do
yield(subject)
......
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