Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Hiltunen <shiltunen@gitlab.com>2021-05-27 11:31:10 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2021-07-12 12:03:19 +0300
commit9ad66b4c23e51abf2cdbe9632a5d676d495bb227 (patch)
treeb059eacbb058b549f94943d7444f988965c7fce0
parent4d07d9b0fc94482ddd88a700624040a0005f031a (diff)
Use repository_generations view in GetPartiallyReplicatedRepositories
GetPartiallyReplicatedRepositories is currently using a window function to get the highest generation from all of the replicas. We've since introduced the repository_generations view which also gets the highest generation across the replicas. Let's simplify the query by reusing the view rather than performing the logic again using the window function.
-rw-r--r--internal/praefect/datastore/repository_store.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/internal/praefect/datastore/repository_store.go b/internal/praefect/datastore/repository_store.go
index b686617e4..57a108a64 100644
--- a/internal/praefect/datastore/repository_store.go
+++ b/internal/praefect/datastore/repository_store.go
@@ -591,7 +591,7 @@ FROM (
relative_path,
repositories.primary,
storage,
- max(storage_repositories.generation) OVER (PARTITION BY virtual_storage, relative_path) - COALESCE(storage_repositories.generation, -1) AS behind_by,
+ repository_generations.generation - COALESCE(storage_repositories.generation, -1) AS behind_by,
repository_assignments.storage IS NOT NULL AS assigned
FROM storage_repositories
FULL JOIN (
@@ -607,6 +607,7 @@ FROM (
)
) AS repository_assignments USING (virtual_storage, relative_path, storage)
JOIN repositories USING (virtual_storage, relative_path)
+ JOIN repository_generations USING (virtual_storage, relative_path)
WHERE virtual_storage = $1
ORDER BY relative_path, "primary", storage
) AS outdated_repositories