Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9428adf9
Commit
9428adf9
authored
May 23, 2020
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix atomic processing bumping a lock_version
parent
eb014d6b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
9 deletions
+14
-9
app/models/commit_status.rb
app/models/commit_status.rb
+4
-2
app/services/projects/update_pages_service.rb
app/services/projects/update_pages_service.rb
+4
-6
changelogs/unreleased/fix-atomic-processing-lock-version.yml
changelogs/unreleased/fix-atomic-processing-lock-version.yml
+5
-0
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+1
-1
No files found.
app/models/commit_status.rb
View file @
9428adf9
...
...
@@ -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?
...
...
app/services/projects/update_pages_service.rb
View file @
9428adf9
...
...
@@ -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
...
...
changelogs/unreleased/fix-atomic-processing-lock-version.yml
0 → 100644
View file @
9428adf9
---
title
:
Fix atomic processing bumping a lock_version
merge_request
:
32914
author
:
type
:
fixed
lib/api/commit_statuses.rb
View file @
9428adf9
...
...
@@ -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'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment