Skip to content
Snippets Groups Projects
Commit 96ddc548 authored by Valery Sizov's avatar Valery Sizov
Browse files

resolve situation with concurent ruuners registration

parent 0783a659
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -25,7 +25,9 @@ class RegisterBuildService
end
 
if build
ActiveRecord::Base.transaction do
# In case when 2 runners try to assign the same build, second runner will be declined
# with StateMachine::InvalidTransition in run! method.
build.with_lock do
build.runner_id = current_runner.id
build.save!
build.run!
Loading
Loading
@@ -33,5 +35,8 @@ class RegisterBuildService
end
 
build
rescue StateMachine::InvalidTransition
nil
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment