diff options
author | Sean Carroll <scarroll@gitlab.com> | 2019-08-30 15:10:55 +0200 |
---|---|---|
committer | Sean Carroll <scarroll@gitlab.com> | 2019-08-30 15:10:55 +0200 |
commit | 94f4cd2df98e5d41ed806e11fcf5c30bc863646a (patch) | |
tree | a1d07571ec8f255e4e0229ac530675156dc5bbcc | |
parent | e4af69a77fb4a2be54b6adfa5ab3cdbfb44aecd2 (diff) | |
download | gitlab-ce-94f4cd2df98e5d41ed806e11fcf5c30bc863646a.tar.gz |
Port EE issue 12996
-rw-r--r-- | app/models/ci/pipeline.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/port-ee-issue-12996.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/optimistic_locking.rb | 3 |
3 files changed, 9 insertions, 3 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 64e372878e6..9e71be32bad 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -460,7 +460,7 @@ module Ci canceled? && auto_canceled_by_id? end - def cancel_running + def cancel_running(retries: nil) retry_optimistic_lock(cancelable_statuses) do |cancelable| cancelable.find_each do |job| yield(job) if block_given? @@ -469,7 +469,7 @@ 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| diff --git a/changelogs/unreleased/port-ee-issue-12996.yml b/changelogs/unreleased/port-ee-issue-12996.yml new file mode 100644 index 00000000000..4731a1c86c5 --- /dev/null +++ b/changelogs/unreleased/port-ee-issue-12996.yml @@ -0,0 +1,5 @@ +--- +title: Backport EE issue 12996 +merge_request: +author: +type: added diff --git a/lib/gitlab/optimistic_locking.rb b/lib/gitlab/optimistic_locking.rb index 0c0f46d3b77..d51d718c826 100644 --- a/lib/gitlab/optimistic_locking.rb +++ b/lib/gitlab/optimistic_locking.rb @@ -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) |