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
33279acb
Commit
33279acb
authored
Apr 04, 2018
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backoff of retrying files missing on primary
parent
2d50b8a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
11 deletions
+51
-11
ee/app/services/geo/file_download_service.rb
ee/app/services/geo/file_download_service.rb
+6
-1
ee/spec/services/geo/file_download_service_spec.rb
ee/spec/services/geo/file_download_service_spec.rb
+45
-10
No files found.
ee/app/services/geo/file_download_service.rb
View file @
33279acb
...
...
@@ -62,10 +62,15 @@ module Geo
registry
.
success
=
mark_as_synced
registry
.
missing_on_primary
=
missing_on_primary
unless
mark_as_synced
retry_later
=
!
registry
.
success
||
registry
.
missing_on_primary
if
retry_later
# We don't limit the amount of retries
registry
.
retry_count
=
(
registry
.
retry_count
||
0
)
+
1
registry
.
retry_at
=
Time
.
now
+
delay
(
registry
.
retry_count
).
seconds
else
registry
.
retry_count
=
0
registry
.
retry_at
=
nil
end
registry
.
save
...
...
ee/spec/services/geo/file_download_service_spec.rb
View file @
33279acb
...
...
@@ -54,6 +54,13 @@ describe Geo::FileDownloadService do
execute!
end
it
'resets the retry fields'
do
execute!
expect
(
registry
.
last
.
reload
.
retry_count
).
to
eq
(
0
)
expect
(
registry
.
last
.
retry_at
).
to
be_nil
end
end
context
'when the file fails to download'
do
...
...
@@ -81,6 +88,15 @@ describe Geo::FileDownloadService do
execute!
end
it
'sets a retry date and increments the retry count'
do
Timecop
.
freeze
do
execute!
expect
(
registry
.
last
.
reload
.
retry_count
).
to
eq
(
1
)
expect
(
registry
.
last
.
retry_at
>
Time
.
now
).
to
be_truthy
end
end
end
context
'when the file is not missing on the primary'
do
...
...
@@ -103,10 +119,12 @@ describe Geo::FileDownloadService do
end
it
'sets a retry date and increments the retry count'
do
execute!
Timecop
.
freeze
do
execute!
expect
(
registry
.
last
.
retry_count
).
to
eq
(
1
)
expect
(
registry
.
last
.
retry_at
).
to
be_present
expect
(
registry
.
last
.
reload
.
retry_count
).
to
eq
(
1
)
expect
(
registry
.
last
.
retry_at
>
Time
.
now
).
to
be_truthy
end
end
end
end
...
...
@@ -116,9 +134,9 @@ describe Geo::FileDownloadService do
context
'for a registered file that failed to sync'
do
let!
(
:registry_entry
)
do
if
file_type
==
'job_artifact'
create
(
:geo_job_artifact_registry
,
success:
false
,
artifact_id:
file
.
id
)
create
(
:geo_job_artifact_registry
,
success:
false
,
artifact_id:
file
.
id
,
retry_count:
3
,
retry_at:
1
.
hour
.
ago
)
else
create
(
:geo_file_registry
,
file_type
.
to_sym
,
success:
false
,
file_id:
file
.
id
)
create
(
:geo_file_registry
,
file_type
.
to_sym
,
success:
false
,
file_id:
file
.
id
,
retry_count:
3
,
retry_at:
1
.
hour
.
ago
)
end
end
...
...
@@ -135,6 +153,13 @@ describe Geo::FileDownloadService do
expect
{
execute!
}.
to
change
{
registry
.
synced
.
count
}.
by
(
1
)
end
it
'resets the retry fields'
do
execute!
expect
(
registry_entry
.
reload
.
retry_count
).
to
eq
(
0
)
expect
(
registry_entry
.
retry_at
).
to
be_nil
end
context
'when the file was marked as missing on the primary'
do
before
do
registry_entry
.
update_column
(
:missing_on_primary
,
true
)
...
...
@@ -181,6 +206,15 @@ describe Geo::FileDownloadService do
execute!
end
it
'sets a retry date and increments the retry count'
do
Timecop
.
freeze
do
execute!
expect
(
registry_entry
.
reload
.
retry_count
).
to
eq
(
4
)
expect
(
registry_entry
.
retry_at
>
Time
.
now
).
to
be_truthy
end
end
end
context
'when the file is not missing on the primary'
do
...
...
@@ -202,12 +236,13 @@ describe Geo::FileDownloadService do
expect
(
registry_entry
.
reload
.
missing_on_primary
).
to
be_falsey
end
it
'
changes the
retry date and increments the retry count'
do
expect
{
execute!
}.
to
change
{
registry_entry
.
reload
.
retry_count
}.
from
(
nil
).
to
(
1
)
end
it
'
sets a
retry date and increments the retry count'
do
Timecop
.
freeze
do
execute!
it
'changes the retry date and increments the retry count'
do
expect
{
execute!
}.
to
change
{
registry_entry
.
reload
.
retry_at
}
expect
(
registry_entry
.
reload
.
retry_count
).
to
eq
(
4
)
expect
(
registry_entry
.
retry_at
>
Time
.
now
).
to
be_truthy
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