Commit 83059f13 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve pipeline optimistic locking implementation

parent 7db9323d
...@@ -5,6 +5,7 @@ module Ci ...@@ -5,6 +5,7 @@ module Ci
include Importable include Importable
include AfterCommitQueue include AfterCommitQueue
include Presentable include Presentable
include Gitlab::OptimisticLocking
belongs_to :project belongs_to :project
belongs_to :user belongs_to :user
...@@ -274,7 +275,7 @@ module Ci ...@@ -274,7 +275,7 @@ module Ci
end end
def cancel_running def cancel_running
Gitlab::OptimisticLocking.retry_lock(cancelable_statuses) do |cancelable| retry_optimistic_lock(cancelable_statuses) do |cancelable|
cancelable.find_each do |job| cancelable.find_each do |job|
yield(job) if block_given? yield(job) if block_given?
job.cancel job.cancel
...@@ -418,7 +419,7 @@ module Ci ...@@ -418,7 +419,7 @@ module Ci
end end
def update_status def update_status
Gitlab::OptimisticLocking.retry_lock(self) do retry_optimistic_lock(self) do
case latest_builds_status case latest_builds_status
when 'pending' then enqueue when 'pending' then enqueue
when 'running' then run when 'running' then run
......
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