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
45115cd0
Commit
45115cd0
authored
Sep 02, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedule a job projects where last sync failed or was updated recently
parent
e21422f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
7 deletions
+35
-7
ee/app/finders/geo/project_updated_recently_finder.rb
ee/app/finders/geo/project_updated_recently_finder.rb
+4
-5
ee/app/workers/geo/secondary/repository_backfill_worker.rb
ee/app/workers/geo/secondary/repository_backfill_worker.rb
+12
-2
ee/spec/workers/geo/secondary/repository_backfill_worker_spec.rb
.../workers/geo/secondary/repository_backfill_worker_spec.rb
+19
-0
No files found.
ee/app/finders/geo/project_updated_recently_finder.rb
View file @
45115cd0
...
...
@@ -10,7 +10,7 @@
# .execute.
module
Geo
class
ProjectUpdatedRecentlyFinder
def
initialize
(
current_node
:,
shard_name
:,
batch_size
:)
def
initialize
(
current_node
:,
shard_name
:,
batch_size:
nil
)
@current_node
=
Geo
::
Fdw
::
GeoNode
.
find
(
current_node
.
id
)
@shard_name
=
shard_name
@batch_size
=
batch_size
...
...
@@ -20,10 +20,9 @@ module Geo
def
execute
return
Geo
::
Fdw
::
Project
.
none
unless
valid_shard?
projects
.
recently_updated
.
within_shards
(
shard_name
)
.
limit
(
batch_size
)
relation
=
projects
.
recently_updated
.
within_shards
(
shard_name
)
relation
=
relation
.
limit
(
batch_size
)
unless
batch_size
.
nil?
relation
end
# rubocop:enable CodeReuse/ActiveRecord
...
...
ee/app/workers/geo/secondary/repository_backfill_worker.rb
View file @
45115cd0
...
...
@@ -21,7 +21,7 @@ module Geo
reason
=
:unknown
begin
connection
.
send_query
(
unsynced_projects_ids
.
to_sql
)
connection
.
send_query
(
"
#{
projects_ids_unsynced
.
to_sql
}
;
#{
project_ids_updated_recently
.
to_sql
}
"
)
connection
.
set_single_row_mode
reason
=
loop
do
...
...
@@ -106,7 +106,7 @@ module Geo
end
# rubocop: disable CodeReuse/ActiveRecord
def
unsynced_projects_ids
def
projects_ids_unsynced
Geo
::
ProjectUnsyncedFinder
.
new
(
current_node:
Gitlab
::
Geo
.
current_node
,
shard_name:
shard_name
)
.
execute
...
...
@@ -114,6 +114,16 @@ module Geo
.
select
(
:id
)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
project_ids_updated_recently
Geo
::
ProjectUpdatedRecentlyFinder
.
new
(
current_node:
Gitlab
::
Geo
.
current_node
,
shard_name:
shard_name
)
.
execute
.
order
(
'project_registry.last_repository_synced_at ASC NULLS FIRST, projects.last_repository_updated_at ASC'
)
.
select
(
:id
)
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
ee/spec/workers/geo/secondary/repository_backfill_worker_spec.rb
View file @
45115cd0
...
...
@@ -69,6 +69,25 @@ describe Geo::Secondary::RepositoryBackfillWorker, :geo, :geo_fdw, :clean_gitlab
subject
.
perform
(
shard_name
)
end
it
'schedules a job for each project where last attempt to sync failed'
do
create
(
:geo_project_registry
,
:sync_failed
)
create
(
:geo_project_registry
,
:synced
)
expect
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_async
).
once
.
and_return
(
true
)
subject
.
perform
(
shard_name
)
end
it
'schedules a job for each synced project updated recently'
do
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
)
create
(
:geo_project_registry
,
:synced
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
)
expect
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_async
).
twice
.
and_return
(
true
)
subject
.
perform
(
shard_name
)
end
it
'respects Geo secondary node max capacity per shard'
do
stub_healthy_shards
([
shard_name
,
'shard2'
,
'shard3'
,
'shard4'
,
'shard5'
])
allow
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_async
).
twice
.
and_return
(
'jid-123'
)
...
...
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