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
cfe5a0c1
Commit
cfe5a0c1
authored
Jul 07, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a lower timeout for sync worker and renew it from within the loop
parent
433ef188
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
app/workers/geo_repository_sync_worker.rb
app/workers/geo_repository_sync_worker.rb
+16
-4
No files found.
app/workers/geo_repository_sync_worker.rb
View file @
cfe5a0c1
...
...
@@ -3,7 +3,7 @@ class GeoRepositorySyncWorker
include
CronjobQueue
LEASE_KEY
=
'geo_repository_sync_worker'
.
freeze
LEASE_TIMEOUT
=
8
.
hours
.
freeze
LEASE_TIMEOUT
=
10
.
minutes
BATCH_SIZE
=
1000
BACKOFF_DELAY
=
5
.
minutes
MAX_CAPACITY
=
25
...
...
@@ -40,6 +40,7 @@ class GeoRepositorySyncWorker
schedule_jobs
break
if
last_batch
break
unless
renew_lease!
sleep
(
1
)
end
...
...
@@ -117,15 +118,26 @@ class GeoRepositorySyncWorker
end
def
try_obtain_lease
lease
=
Gitlab
::
ExclusiveLease
.
new
(
LEASE_KEY
,
timeout:
LEASE_TIMEOUT
)
.
try_obtain
lease
=
exclusive_lease
.
try_obtain
return
unless
lease
unless
lease
logger
.
info
"Cannot obtain an exclusive lease. There must be another worker already in execution."
return
end
begin
yield
lease
ensure
Gitlab
::
ExclusiveLease
.
cancel
(
LEASE_KEY
,
lease
)
release_lease
(
lease
)
end
end
def
exclusive_lease
@lease
||=
Gitlab
::
ExclusiveLease
.
new
(
LEASE_KEY
,
timeout:
LEASE_TIMEOUT
)
end
def
renew_lease!
exclusive_lease
.
renew
end
def
release_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