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
f294aa46
Commit
f294aa46
authored
Sep 15, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Does not update repository statistics on a read-only instance
GitGarbageCollectWorker may be run on a Geo secondary
parent
27c57663
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
app/workers/git_garbage_collect_worker.rb
app/workers/git_garbage_collect_worker.rb
+8
-4
spec/workers/git_garbage_collect_worker_spec.rb
spec/workers/git_garbage_collect_worker_spec.rb
+14
-7
No files found.
app/workers/git_garbage_collect_worker.rb
View file @
f294aa46
...
...
@@ -37,10 +37,7 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker
# Refresh the branch cache in case garbage collection caused a ref lookup to fail
flush_ref_caches
(
project
)
if
task
==
:gc
if
task
!=
:pack_refs
project
.
repository
.
expire_statistics_caches
Projects
::
UpdateStatisticsService
.
new
(
project
,
nil
,
statistics:
[
:repository_size
,
:lfs_objects_size
]).
execute
end
update_repository_statistics
(
project
)
if
task
!=
:pack_refs
# In case pack files are deleted, release libgit2 cache and open file
# descriptors ASAP instead of waiting for Ruby garbage collection
...
...
@@ -106,6 +103,13 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker
project
.
repository
.
has_visible_content?
end
def
update_repository_statistics
(
project
)
project
.
repository
.
expire_statistics_caches
return
if
Gitlab
::
Database
.
read_only?
# GitGarbageCollectWorker may be run on a Geo secondary
Projects
::
UpdateStatisticsService
.
new
(
project
,
nil
,
statistics:
[
:repository_size
,
:lfs_objects_size
]).
execute
end
def
bitmaps_enabled?
Gitlab
::
CurrentSettings
.
housekeeping_bitmaps_enabled
end
...
...
spec/workers/git_garbage_collect_worker_spec.rb
View file @
f294aa46
...
...
@@ -25,12 +25,18 @@ RSpec.describe GitGarbageCollectWorker do
end
shared_examples
'it updates the project statistics'
do
specify
do
expect_any_instance_of
(
Projects
::
UpdateStatisticsService
).
to
receive
(
:execute
).
and_call_original
expect
(
Projects
::
UpdateStatisticsService
)
.
to
receive
(
:new
)
.
with
(
project
,
nil
,
statistics:
[
:repository_size
,
:lfs_objects_size
])
.
and_call_original
it
'updates the project statistics'
do
expect_next_instance_of
(
Projects
::
UpdateStatisticsService
,
project
,
nil
,
statistics:
[
:repository_size
,
:lfs_objects_size
])
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
and_call_original
end
subject
.
perform
(
*
params
)
end
it
'does nothing if the database is read-only'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
)
{
true
}
expect_any_instance_of
(
Projects
::
UpdateStatisticsService
).
not_to
receive
(
:execute
)
subject
.
perform
(
*
params
)
end
...
...
@@ -141,7 +147,8 @@ RSpec.describe GitGarbageCollectWorker do
end
it
'does nothing if the database is read-only'
do
expect
(
Gitlab
::
Database
).
to
receive
(
:read_only?
)
{
true
}
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
)
{
true
}
expect_any_instance_of
(
Gitlab
::
Cleanup
::
OrphanLfsFileReferences
).
not_to
receive
(
:run!
)
subject
.
perform
(
*
params
)
...
...
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