Remove lock on the table

This commit is contained in:
Wedge 2018-04-09 15:04:16 +03:00
parent 31f68329b3
commit 7c6bc82991
1 changed files with 52 additions and 54 deletions

View File

@ -11,63 +11,61 @@ module AbfWorker
def real_perform def real_perform
@subject_class = BuildList @subject_class = BuildList
subject.with_lock do unless subject.valid? && restart_task
unless subject.valid? && restart_task if options['feedback_from_user']
if options['feedback_from_user'] user = User.find options['feedback_from_user']
user = User.find options['feedback_from_user'] raise ActiveRecord::Rollback if !user.system? && subject.builder != user
raise ActiveRecord::Rollback if !user.system? && subject.builder != user end
fill_container_data if status != STARTED
unless subject.valid?
subject.build_error(false)
subject.save(validate: false)
return
end
if options['hostname']
subject.update_attribute(:hostname, options['hostname'])
end
if options['fail_reason']
subject.update_attribute(:fail_reason, options['fail_reason'])
end
if options['commit_hash']
subject.update_attribute(:commit_hash, options['commit_hash'])
end
rerunning_tests = subject.rerunning_tests?
case status
when COMPLETED
subject.build_success
if subject.can_auto_publish? && subject.can_publish?
subject.publish
elsif subject.auto_publish_into_testing? && subject.can_publish_into_testing?
subject.publish_into_testing
end
when FAILED
case options['exit_status'].to_i
when EXIT_CODE_UNPERMITTED_ARCHITECTURE
subject.unpermitted_arch
else
subject.build_error
end end
fill_container_data if status != STARTED when STARTED
subject.start_build
when CANCELED
subject.build_canceled
when TESTS_FAILED
subject.tests_failed
end
unless subject.valid? if !rerunning_tests && [TESTS_FAILED, COMPLETED].include?(status)
subject.build_error(false) subject.publish_container if subject.auto_create_container?
subject.save(validate: false)
return
end
if options['hostname']
subject.update_attribute(:hostname, options['hostname'])
end
if options['fail_reason']
subject.update_attribute(:fail_reason, options['fail_reason'])
end
if options['commit_hash']
subject.update_attribute(:commit_hash, options['commit_hash'])
end
rerunning_tests = subject.rerunning_tests?
case status
when COMPLETED
subject.build_success
if subject.can_auto_publish? && subject.can_publish?
subject.publish
elsif subject.auto_publish_into_testing? && subject.can_publish_into_testing?
subject.publish_into_testing
end
when FAILED
case options['exit_status'].to_i
when EXIT_CODE_UNPERMITTED_ARCHITECTURE
subject.unpermitted_arch
else
subject.build_error
end
when STARTED
subject.start_build
when CANCELED
subject.build_canceled
when TESTS_FAILED
subject.tests_failed
end
if !rerunning_tests && [TESTS_FAILED, COMPLETED].include?(status)
subject.publish_container if subject.auto_create_container?
end
end end
end end
end end