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
3811973a
Commit
3811973a
authored
Nov 17, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cap the Geo retry_at value to prevent out of range timestamps
Part of #4083
parent
eab9110f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
app/services/geo/base_sync_service.rb
app/services/geo/base_sync_service.rb
+10
-1
spec/services/geo/repository_sync_service_spec.rb
spec/services/geo/repository_sync_service_spec.rb
+19
-0
No files found.
app/services/geo/base_sync_service.rb
View file @
3811973a
...
...
@@ -136,7 +136,7 @@ module Geo
if
started_at
attrs
[
"last_
#{
type
}
_synced_at"
]
=
started_at
attrs
[
"
#{
type
}
_retry_count"
]
=
retry_count
+
1
attrs
[
"
#{
type
}
_retry_at"
]
=
Time
.
now
+
delay
(
attrs
[
"
#{
type
}
_retry_count"
]).
seconds
attrs
[
"
#{
type
}
_retry_at"
]
=
next_retry_time
(
attrs
[
"
#{
type
}
_retry_count"
])
end
if
finished_at
...
...
@@ -210,5 +210,14 @@ module Geo
raise
Gitlab
::
Shell
::
Error
,
'Can not move temporary repository'
end
end
# To prevent the retry time from storing invalid dates in the database,
# cap the max time to a week plus some random jitter value.
def
next_retry_time
(
retry_count
)
proposed_time
=
Time
.
now
+
delay
(
retry_count
).
seconds
max_future_time
=
Time
.
now
+
7
.
days
+
delay
(
1
).
seconds
[
proposed_time
,
max_future_time
].
min
end
end
end
spec/services/geo/repository_sync_service_spec.rb
View file @
3811973a
...
...
@@ -189,6 +189,25 @@ describe Geo::RepositorySyncService do
subject
.
execute
end
it
'successfully redownloads the file even if the retry time exceeds max value'
do
timestamp
=
Time
.
now
.
utc
registry
=
create
(
:geo_project_registry
,
project:
project
,
repository_retry_count:
Geo
::
BaseSyncService
::
RETRY_BEFORE_REDOWNLOAD
+
2000
,
repository_retry_at:
timestamp
,
force_to_redownload_repository:
true
)
subject
.
execute
# The repository should be redownloaded and cleared without errors. If
# the timestamp were not capped, we would have seen a "timestamp out
# of range" in the first update to the project registry.
registry
.
reload
expect
(
registry
.
repository_retry_at
).
to
be_nil
end
end
context
'secondary replicates over SSH'
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