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
fdd33901
Commit
fdd33901
authored
Sep 11, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Geo repository sync performance for larger databases
parent
dfe00667
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
app/models/geo_node.rb
app/models/geo_node.rb
+21
-0
app/workers/geo/repository_sync_worker.rb
app/workers/geo/repository_sync_worker.rb
+4
-5
changelogs/unreleased-ee/3269-speed-up-cross-db-pluck.yml
changelogs/unreleased-ee/3269-speed-up-cross-db-pluck.yml
+5
-0
No files found.
app/models/geo_node.rb
View file @
fdd33901
...
@@ -135,6 +135,27 @@ class GeoNode < ActiveRecord::Base
...
@@ -135,6 +135,27 @@ class GeoNode < ActiveRecord::Base
end
end
end
end
# These are projects that meet the project restriction but haven't yet been
# synced (i.e., do not yet have a project registry entry).
#
# This query requires data from two different databases, and unavoidably
# plucks a list of project IDs from one into the other. This will not scale
# well with the number of synchronized projects - the query will increase
# linearly in size - so this should be replaced with postgres_fdw ASAP.
def
unsynced_projects
registry_project_ids
=
project_registries
.
pluck
(
:project_id
)
return
projects
if
registry_project_ids
.
empty?
joined_relation
=
projects
.
joins
(
<<~
SQL
)
LEFT OUTER JOIN
(VALUES
#{
registry_project_ids
.
map
{
|
id
|
"(
#{
id
}
, 't')"
}
.join(',')})
project_registry(project_id, registry_present)
ON projects.id = project_registry.project_id
SQL
joined_relation
.
where
(
project_registry:
{
registry_present:
[
nil
,
false
]
})
end
def
uploads
def
uploads
if
restricted_project_ids
if
restricted_project_ids
uploads_table
=
Upload
.
arel_table
uploads_table
=
Upload
.
arel_table
...
...
app/workers/geo/repository_sync_worker.rb
View file @
fdd33901
...
@@ -23,11 +23,10 @@ module Geo
...
@@ -23,11 +23,10 @@ module Geo
end
end
def
find_project_ids_not_synced
def
find_project_ids_not_synced
current_node
.
projects
current_node
.
unsynced_projects
.
where
.
not
(
id:
Geo
::
ProjectRegistry
.
pluck
(
:project_id
))
.
reorder
(
last_repository_updated_at: :desc
)
.
order
(
last_repository_updated_at: :desc
)
.
limit
(
db_retrieve_batch_size
)
.
limit
(
db_retrieve_batch_size
)
.
pluck
(
:id
)
.
pluck
(
:id
)
end
end
def
find_project_ids_updated_recently
def
find_project_ids_updated_recently
...
...
changelogs/unreleased-ee/3269-speed-up-cross-db-pluck.yml
0 → 100644
View file @
fdd33901
---
title
:
Improve Geo repository sync performance for larger databases
merge_request
:
2887
author
:
type
:
fixed
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