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
80c3bfb2
Commit
80c3bfb2
authored
Oct 09, 2019
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup feature flag iid_always_track
Closes
https://gitlab.com/gitlab-org/gitlab/issues/30515
parent
82f0365d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
36 deletions
+17
-36
app/models/concerns/atomic_internal_id.rb
app/models/concerns/atomic_internal_id.rb
+1
-2
changelogs/unreleased/ab-iid-unnecessary-locks.yml
changelogs/unreleased/ab-iid-unnecessary-locks.yml
+5
-0
spec/models/concerns/atomic_internal_id_spec.rb
spec/models/concerns/atomic_internal_id_spec.rb
+11
-30
spec/support/shared_examples/models/atomic_internal_id_shared_examples.rb
...red_examples/models/atomic_internal_id_shared_examples.rb
+0
-4
No files found.
app/models/concerns/atomic_internal_id.rb
View file @
80c3bfb2
...
@@ -57,8 +57,7 @@ module AtomicInternalId
...
@@ -57,8 +57,7 @@ module AtomicInternalId
end
end
define_method
(
"track_
#{
scope
}
_
#{
column
}
!"
)
do
define_method
(
"track_
#{
scope
}
_
#{
column
}
!"
)
do
iid_always_track
=
Feature
.
enabled?
(
:iid_always_track
,
default_enabled:
true
)
return
unless
@internal_id_needs_tracking
return
unless
@internal_id_needs_tracking
||
iid_always_track
scope_value
=
internal_id_read_scope
(
scope
)
scope_value
=
internal_id_read_scope
(
scope
)
return
unless
scope_value
return
unless
scope_value
...
...
changelogs/unreleased/ab-iid-unnecessary-locks.yml
0 → 100644
View file @
80c3bfb2
---
title
:
Avoid unnecessary locks on internal_ids
merge_request
:
18328
author
:
type
:
performance
spec/models/concerns/atomic_internal_id_spec.rb
View file @
80c3bfb2
...
@@ -22,41 +22,22 @@ describe AtomicInternalId do
...
@@ -22,41 +22,22 @@ describe AtomicInternalId do
end
end
context
'when value is set by ensure_project_iid!'
do
context
'when value is set by ensure_project_iid!'
do
context
'with iid_always_track false'
do
it
'does not track the value'
do
before
do
expect
(
InternalId
).
not_to
receive
(
:track_greatest
)
stub_feature_flags
(
iid_always_track:
false
)
end
it
'does not track the value'
do
milestone
.
ensure_project_iid!
expect
(
InternalId
).
not_to
receive
(
:track_greatest
)
subject
milestone
.
ensure_project_iid!
subject
end
it
'tracks the iid for the scope that is actually present'
do
milestone
.
iid
=
external_iid
expect
(
InternalId
).
to
receive
(
:track_greatest
).
once
.
with
(
milestone
,
scope_attrs
,
usage
,
external_iid
,
anything
)
expect
(
InternalId
).
not_to
receive
(
:generate_next
)
# group scope is not present here, the milestone does not have a group
milestone
.
track_group_iid!
subject
end
end
end
context
'with iid_always_track enabled'
do
it
'tracks the iid for the scope that is actually present'
do
before
do
milestone
.
iid
=
external_iid
stub_feature_flags
(
iid_always_track:
true
)
end
it
'does not track the value'
do
expect
(
InternalId
).
to
receive
(
:track_greatest
).
once
.
with
(
milestone
,
scope_attrs
,
usage
,
external_iid
,
anything
)
expect
(
InternalId
).
to
receive
(
:track_greates
t
)
expect
(
InternalId
).
not_to
receive
(
:generate_nex
t
)
milestone
.
ensure_project_iid!
# group scope is not present here, the milestone does not have a group
subject
milestone
.
track_group_iid!
end
subject
end
end
end
end
end
end
...
...
spec/support/shared_examples/models/atomic_internal_id_shared_examples.rb
View file @
80c3bfb2
...
@@ -47,10 +47,6 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
...
@@ -47,10 +47,6 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
end
end
describe
'internal id generation'
do
describe
'internal id generation'
do
before
do
stub_feature_flags
(
iid_always_track:
false
)
end
subject
{
instance
.
save!
}
subject
{
instance
.
save!
}
it
'calls InternalId.generate_next and sets internal id attribute'
do
it
'calls InternalId.generate_next and sets internal id attribute'
do
...
...
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