Commit 9428adf9 authored by Kamil Trzciński's avatar Kamil Trzciński

Fix atomic processing bumping a lock_version

parent eb014d6b
......@@ -189,8 +189,10 @@ class CommitStatus < ApplicationRecord
end
def self.update_as_processed!
# Marks items as processed, and increases `lock_version` (Optimisitc Locking)
update_all('processed=TRUE, lock_version=COALESCE(lock_version,0)+1')
# Marks items as processed
# we do not increase `lock_version`, as we are the one
# holding given lock_version (Optimisitc Locking)
update_all(processed: true)
end
def self.locking_enabled?
......
......@@ -2,8 +2,6 @@
module Projects
class UpdatePagesService < BaseService
include Gitlab::OptimisticLocking
InvalidStateError = Class.new(StandardError)
FailedToExtractError = Class.new(StandardError)
......@@ -25,8 +23,8 @@ module Projects
# Create status notifying the deployment of pages
@status = create_status
retry_optimistic_lock(@status, &:enqueue!)
retry_optimistic_lock(@status, &:run!)
@status.enqueue!
@status.run!
raise InvalidStateError, 'missing pages artifacts' unless build.artifacts?
raise InvalidStateError, 'build SHA is outdated for this ref' unless latest?
......@@ -53,7 +51,7 @@ module Projects
private
def success
retry_optimistic_lock(@status, &:success)
@status.success
@project.mark_pages_as_deployed
super
end
......@@ -63,7 +61,7 @@ module Projects
log_error("Projects::UpdatePagesService: #{message}")
@status.allow_failure = !latest?
@status.description = message
retry_optimistic_lock(@status) { |status| status.drop(:script_failure) }
@status.drop(:script_failure)
super
end
......
---
title: Fix atomic processing bumping a lock_version
merge_request: 32914
author:
type: fixed
......@@ -106,7 +106,7 @@ module API
status.enqueue!
when 'running'
status.enqueue
Gitlab::OptimisticLocking.retry_lock(status, &:run!)
status.run!
when 'success'
status.success!
when 'failed'
......
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