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
b5fdc310
Commit
b5fdc310
authored
May 02, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
5ca2873e
20650400
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
4 deletions
+52
-4
app/services/projects/housekeeping_service.rb
app/services/projects/housekeeping_service.rb
+5
-2
app/workers/git_garbage_collect_worker.rb
app/workers/git_garbage_collect_worker.rb
+9
-2
changelogs/unreleased/use-pg-10-7.yml
changelogs/unreleased/use-pg-10-7.yml
+5
-0
lib/gitlab/gitaly_client/ref_service.rb
lib/gitlab/gitaly_client/ref_service.rb
+6
-0
spec/lib/gitlab/gitaly_client/ref_service_spec.rb
spec/lib/gitlab/gitaly_client/ref_service_spec.rb
+11
-0
spec/services/projects/housekeeping_service_spec.rb
spec/services/projects/housekeeping_service_spec.rb
+3
-0
spec/workers/git_garbage_collect_worker_spec.rb
spec/workers/git_garbage_collect_worker_spec.rb
+13
-0
No files found.
app/services/projects/housekeeping_service.rb
View file @
b5fdc310
...
@@ -11,6 +11,7 @@ module Projects
...
@@ -11,6 +11,7 @@ module Projects
class
HousekeepingService
<
BaseService
class
HousekeepingService
<
BaseService
# Timeout set to 24h
# Timeout set to 24h
LEASE_TIMEOUT
=
86400
LEASE_TIMEOUT
=
86400
PACK_REFS_PERIOD
=
6
class
LeaseTaken
<
StandardError
class
LeaseTaken
<
StandardError
def
to_s
def
to_s
...
@@ -76,13 +77,15 @@ module Projects
...
@@ -76,13 +77,15 @@ module Projects
:gc
:gc
elsif
pushes_since_gc
%
full_repack_period
==
0
elsif
pushes_since_gc
%
full_repack_period
==
0
:full_repack
:full_repack
els
e
els
if
pushes_since_gc
%
repack_period
==
0
:incremental_repack
:incremental_repack
else
:pack_refs
end
end
end
end
def
period_match?
def
period_match?
[
gc_period
,
full_repack_period
,
repack_period
].
any?
{
|
period
|
pushes_since_gc
%
period
==
0
}
[
gc_period
,
full_repack_period
,
repack_period
,
PACK_REFS_PERIOD
].
any?
{
|
period
|
pushes_since_gc
%
period
==
0
}
end
end
def
housekeeping_enabled?
def
housekeeping_enabled?
...
...
app/workers/git_garbage_collect_worker.rb
View file @
b5fdc310
...
@@ -29,7 +29,7 @@ class GitGarbageCollectWorker
...
@@ -29,7 +29,7 @@ class GitGarbageCollectWorker
# Refresh the branch cache in case garbage collection caused a ref lookup to fail
# Refresh the branch cache in case garbage collection caused a ref lookup to fail
flush_ref_caches
(
project
)
if
task
==
:gc
flush_ref_caches
(
project
)
if
task
==
:gc
project
.
repository
.
expire_statistics_caches
project
.
repository
.
expire_statistics_caches
if
task
!=
:pack_refs
# In case pack files are deleted, release libgit2 cache and open file
# In case pack files are deleted, release libgit2 cache and open file
# descriptors ASAP instead of waiting for Ruby garbage collection
# descriptors ASAP instead of waiting for Ruby garbage collection
...
@@ -58,7 +58,12 @@ class GitGarbageCollectWorker
...
@@ -58,7 +58,12 @@ class GitGarbageCollectWorker
## `repository` has to be a Gitlab::Git::Repository
## `repository` has to be a Gitlab::Git::Repository
def
gitaly_call
(
task
,
repository
)
def
gitaly_call
(
task
,
repository
)
client
=
Gitlab
::
GitalyClient
::
RepositoryService
.
new
(
repository
)
client
=
if
task
==
:pack_refs
Gitlab
::
GitalyClient
::
RefService
.
new
(
repository
)
else
Gitlab
::
GitalyClient
::
RepositoryService
.
new
(
repository
)
end
case
task
case
task
when
:gc
when
:gc
client
.
garbage_collect
(
bitmaps_enabled?
)
client
.
garbage_collect
(
bitmaps_enabled?
)
...
@@ -66,6 +71,8 @@ class GitGarbageCollectWorker
...
@@ -66,6 +71,8 @@ class GitGarbageCollectWorker
client
.
repack_full
(
bitmaps_enabled?
)
client
.
repack_full
(
bitmaps_enabled?
)
when
:incremental_repack
when
:incremental_repack
client
.
repack_incremental
client
.
repack_incremental
when
:pack_refs
client
.
pack_refs
end
end
rescue
GRPC
::
NotFound
=>
e
rescue
GRPC
::
NotFound
=>
e
Gitlab
::
GitLogger
.
error
(
"
#{
__method__
}
failed:
\n
Repository not found"
)
Gitlab
::
GitLogger
.
error
(
"
#{
__method__
}
failed:
\n
Repository not found"
)
...
...
changelogs/unreleased/use-pg-10-7.yml
0 → 100644
View file @
b5fdc310
---
title
:
Use PostgreSQL 10.7 in tests
merge_request
:
28020
author
:
type
:
other
lib/gitlab/gitaly_client/ref_service.rb
View file @
b5fdc310
...
@@ -239,6 +239,12 @@ module Gitlab
...
@@ -239,6 +239,12 @@ module Gitlab
messages
messages
end
end
def
pack_refs
request
=
Gitaly
::
PackRefsRequest
.
new
(
repository:
@gitaly_repo
)
GitalyClient
.
call
(
@storage
,
:ref_service
,
:pack_refs
,
request
)
end
private
private
def
consume_refs_response
(
response
)
def
consume_refs_response
(
response
)
...
...
spec/lib/gitlab/gitaly_client/ref_service_spec.rb
View file @
b5fdc310
...
@@ -165,4 +165,15 @@ describe Gitlab::GitalyClient::RefService do
...
@@ -165,4 +165,15 @@ describe Gitlab::GitalyClient::RefService do
client
.
delete_refs
(
except_with_prefixes:
prefixes
)
client
.
delete_refs
(
except_with_prefixes:
prefixes
)
end
end
end
end
describe
'#pack_refs'
do
it
'sends a pack_refs message'
do
expect_any_instance_of
(
Gitaly
::
RefService
::
Stub
)
.
to
receive
(
:pack_refs
)
.
with
(
gitaly_request_with_path
(
storage_name
,
relative_path
),
kind_of
(
Hash
))
.
and_return
(
double
(
:pack_refs_response
))
client
.
pack_refs
end
end
end
end
spec/services/projects/housekeeping_service_spec.rb
View file @
b5fdc310
...
@@ -81,6 +81,9 @@ describe Projects::HousekeepingService do
...
@@ -81,6 +81,9 @@ describe Projects::HousekeepingService do
# At push 10, 20, ... (except those above)
# At push 10, 20, ... (except those above)
expect
(
GitGarbageCollectWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
:incremental_repack
,
:the_lease_key
,
:the_uuid
)
expect
(
GitGarbageCollectWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
:incremental_repack
,
:the_lease_key
,
:the_uuid
)
.
exactly
(
16
).
times
.
exactly
(
16
).
times
# At push 6, 12, 18, ... (except those above)
expect
(
GitGarbageCollectWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
:pack_refs
,
:the_lease_key
,
:the_uuid
)
.
exactly
(
27
).
times
201
.
times
do
201
.
times
do
subject
.
increment!
subject
.
increment!
...
...
spec/workers/git_garbage_collect_worker_spec.rb
View file @
b5fdc310
...
@@ -115,6 +115,19 @@ describe GitGarbageCollectWorker do
...
@@ -115,6 +115,19 @@ describe GitGarbageCollectWorker do
end
end
end
end
context
"pack_refs"
do
before
do
expect
(
subject
).
to
receive
(
:get_lease_uuid
).
and_return
(
lease_uuid
)
end
it
"calls Gitaly"
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
RefService
).
to
receive
(
:pack_refs
)
.
and_return
(
nil
)
subject
.
perform
(
project
.
id
,
:pack_refs
,
lease_key
,
lease_uuid
)
end
end
context
"repack_incremental"
do
context
"repack_incremental"
do
before
do
before
do
expect
(
subject
).
to
receive
(
:get_lease_uuid
).
and_return
(
lease_uuid
)
expect
(
subject
).
to
receive
(
:get_lease_uuid
).
and_return
(
lease_uuid
)
...
...
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