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
07f36f22
Commit
07f36f22
authored
Oct 07, 2020
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that only persisted chunk can be flushed
parent
7d9f4319
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
app/models/ci/build_trace_chunk.rb
app/models/ci/build_trace_chunk.rb
+3
-1
spec/models/ci/build_trace_chunk_spec.rb
spec/models/ci/build_trace_chunk_spec.rb
+8
-0
No files found.
app/models/ci/build_trace_chunk.rb
View file @
07f36f22
...
@@ -138,13 +138,15 @@ module Ci
...
@@ -138,13 +138,15 @@ module Ci
#
#
def
persist_data!
def
persist_data!
in_lock
(
*
lock_params
)
do
# exclusive Redis lock is acquired first
in_lock
(
*
lock_params
)
do
# exclusive Redis lock is acquired first
raise
FailedToPersistDataError
,
'Modifed build trace chunk detected'
if
has_changes_to_save?
self
.
reset
.
then
do
|
chunk
|
# we ensure having latest lock_version
self
.
reset
.
then
do
|
chunk
|
# we ensure having latest lock_version
chunk
.
unsafe_persist_data!
# we migrate the data and update data store
chunk
.
unsafe_persist_data!
# we migrate the data and update data store
end
end
end
end
rescue
ActiveRecord
::
StaleObjectError
rescue
ActiveRecord
::
StaleObjectError
raise
FailedToPersistDataError
,
<<~
MSG
raise
FailedToPersistDataError
,
<<~
MSG
d
ata migration race condition detected
D
ata migration race condition detected
store:
#{
data_store
}
store:
#{
data_store
}
build:
#{
build
.
id
}
build:
#{
build
.
id
}
...
...
spec/models/ci/build_trace_chunk_spec.rb
View file @
07f36f22
...
@@ -597,6 +597,14 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
...
@@ -597,6 +597,14 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
expect
{
build_trace_chunk
.
persist_data!
}
expect
{
build_trace_chunk
.
persist_data!
}
.
to
raise_error
(
described_class
::
FailedToPersistDataError
)
.
to
raise_error
(
described_class
::
FailedToPersistDataError
)
end
end
it
'does not allow flushing unpersisted chunk'
do
build_trace_chunk
.
checksum
=
'12345'
expect
{
build_trace_chunk
.
persist_data!
}
.
to
raise_error
(
described_class
::
FailedToPersistDataError
,
/Modifed build trace chunk detected/
)
end
end
end
end
end
end
end
...
...
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