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
2272974a
Commit
2272974a
authored
Feb 02, 2021
by
Mike Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix concurrent VerificationBatchWorkers
parent
ea8972d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
ee/lib/gitlab/geo/verification_state.rb
ee/lib/gitlab/geo/verification_state.rb
+15
-1
No files found.
ee/lib/gitlab/geo/verification_state.rb
View file @
2272974a
...
@@ -169,11 +169,25 @@ module Gitlab
...
@@ -169,11 +169,25 @@ module Gitlab
UPDATE
#{
table_name
}
UPDATE
#{
table_name
}
SET "verification_state" =
#{
started_enum_value
}
,
SET "verification_state" =
#{
started_enum_value
}
,
"verification_started_at" = NOW()
"verification_started_at" = NOW()
WHERE
#{
self
.
verification_state_model_key
}
IN (
#{
relation
.
select
(
self
.
verification_state_model_key
).
to_sql
}
)
WHERE
#{
self
.
verification_state_model_key
}
IN (
#{
start_verification_batch_subselect
(
relation
).
to_sql
}
)
RETURNING
#{
self
.
verification_state_model_key
}
RETURNING
#{
self
.
verification_state_model_key
}
SQL
SQL
end
end
# This query locks the rows during the transaction, and skips locked
# rows so that this query can be run concurrently, safely and reasonably
# efficiently.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/300051#note_496889565
#
# @param [ActiveRecord::Relation] relation with appropriate where, order, and limit defined
# @return [String] SQL statement which selects the primary keys to update
def
start_verification_batch_subselect
(
relation
)
relation
.
select
(
self
.
verification_state_model_key
)
.
lock
(
'FOR UPDATE SKIP LOCKED'
)
# rubocop:disable CodeReuse/ActiveRecord
end
# Overridden in ReplicableRegistry
# Overridden in ReplicableRegistry
def
verification_state_model_key
def
verification_state_model_key
self
.
primary_key
self
.
primary_key
...
...
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