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
1f1caf53
Commit
1f1caf53
authored
Jun 26, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
7acf5dc9
4b7f053a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
19 deletions
+41
-19
changelogs/unreleased/sh-cache-negative-entries-find-commit.yml
...logs/unreleased/sh-cache-negative-entries-find-commit.yml
+5
-0
lib/gitlab/gitaly_client/commit_service.rb
lib/gitlab/gitaly_client/commit_service.rb
+22
-18
spec/lib/gitlab/gitaly_client/commit_service_spec.rb
spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+13
-0
spec/models/internal_id_spec.rb
spec/models/internal_id_spec.rb
+1
-1
No files found.
changelogs/unreleased/sh-cache-negative-entries-find-commit.yml
0 → 100644
View file @
1f1caf53
---
title
:
Allow caching of negative FindCommit matches
merge_request
:
29952
author
:
type
:
performance
lib/gitlab/gitaly_client/commit_service.rb
View file @
1f1caf53
...
...
@@ -271,26 +271,30 @@ module Gitlab
end
def
find_commit
(
revision
)
if
Gitlab
::
SafeRequestStore
.
active?
# We don't use Gitlab::SafeRequestStore.fetch(key) { ... } directly
# because `revision` can be a branch name, so we can't use it as a ke
y
# as it could point to another commit later on (happens a lot in
# tests).
key
=
{
storage:
@gitaly_repo
.
storage_name
,
relative_path:
@gitaly_repo
.
relative_path
,
commit_id:
revision
}
return
Gitlab
::
SafeRequestStore
[
key
]
if
Gitlab
::
SafeRequestStore
.
exist?
(
key
)
commit
=
call_find_commit
(
revision
)
return
unless
commit
key
[
:commit_id
]
=
commit
.
id
unless
GitalyClient
.
ref_name_caching_allowed?
return
call_find_commit
(
revision
)
unless
Gitlab
::
SafeRequestStore
.
active?
# We don't use Gitlab::SafeRequestStore.fetch(key) { ... } directl
y
# because `revision` can be a branch name, so we can't use it as a key
# as it could point to another commit later on (happens a lot in
# tests).
key
=
{
storage:
@gitaly_repo
.
storage_name
,
relative_path:
@gitaly_repo
.
relative_path
,
commit_id:
revision
}
return
Gitlab
::
SafeRequestStore
[
key
]
if
Gitlab
::
SafeRequestStore
.
exist?
(
key
)
commit
=
call_find_commit
(
revision
)
if
GitalyClient
.
ref_name_caching_allowed?
Gitlab
::
SafeRequestStore
[
key
]
=
commit
else
call_find_commit
(
revision
)
return
commit
end
return
unless
commit
key
[
:commit_id
]
=
commit
.
id
Gitlab
::
SafeRequestStore
[
key
]
=
commit
end
# rubocop: disable CodeReuse/ActiveRecord
...
...
spec/lib/gitlab/gitaly_client/commit_service_spec.rb
View file @
1f1caf53
...
...
@@ -223,6 +223,19 @@ describe Gitlab::GitalyClient::CommitService do
end
context
'when caching of the ref name is enabled'
do
it
'caches negative entries'
do
expect_any_instance_of
(
Gitaly
::
CommitService
::
Stub
).
to
receive
(
:find_commit
).
once
.
and_return
(
double
(
commit:
nil
))
commit
=
nil
2
.
times
do
::
Gitlab
::
GitalyClient
.
allow_ref_name_caching
do
commit
=
described_class
.
new
(
repository
).
find_commit
(
'master'
)
end
end
expect
(
commit
).
to
eq
(
nil
)
end
it
'returns a cached commit'
do
expect_any_instance_of
(
Gitaly
::
CommitService
::
Stub
).
to
receive
(
:find_commit
).
once
.
and_return
(
double
(
commit:
commit_dbl
))
...
...
spec/models/internal_id_spec.rb
View file @
1f1caf53
...
...
@@ -158,7 +158,7 @@ describe InternalId do
before
do
described_class
.
reset_column_information
# Project factory will also call the current_version
expect
(
ActiveRecord
::
Migrator
).
to
receive
(
:current_version
).
twice
.
and_return
(
InternalId
::
REQUIRED_SCHEMA_VERSION
-
1
)
expect
(
ActiveRecord
::
Migrator
).
to
receive
(
:current_version
).
at_least
(
:once
)
.
and_return
(
InternalId
::
REQUIRED_SCHEMA_VERSION
-
1
)
end
it
'does not reset any of the iids'
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