Geo - Selective sync by namespace is broken
Summary
The legacy queries to retrieve projects/files to synchronize are broken: WARN: ActiveRecord::StatementInvalid: PG::InvalidRecursion: ERROR: recursive query "base_and_descendants" does not have the form non-recursive-term UNION
.
s not have the form non-recursive-term UNION [ALL] recursive-term
14:02:49 rails-background-jobs.1 | LINE 4: ...HERE "projects"."namespace_id" IN (WITH RECURSIVE "base_and_...
14:02:49 rails-background-jobs.1 | ^
14:02:49 rails-background-jobs.1 | : SELECT "projects"."id" FROM "projects" LEFT OUTER JOIN
14:02:49 rails-background-jobs.1 | (VALUES (257, 't'),(40, 't'),(31, 't'),(33, 't'),(26, 't'),(27, 't'),(36, 't'),(50, 't'),(56, 't'),(60, 't'),(62, 't'),(61, 't'),(1, 't'),(66, 't'),(2, 't'),(73, 't'),(5, 't'),(4, 't'),(75, 't'),(6, 't'),(3, 't'),(78, 't'),(13, 't'),(79, 't'),(12, 't'), ... ,(1763, 't'))
14:02:49 rails-background-jobs.1 | registry(id, registry_present)
14:02:49 rails-background-jobs.1 | ON projects.id = registry.id WHERE "projects"."namespace_id" IN (WITH RECURSIVE "base_and_descendants" AS (SELECT "namespaces".* FROM "namespaces", "base_and_descendants" WHERE "namespaces"."parent_id" = "base_and_descendants"."id") SELECT "id" FROM "base_and_descendants" AS "namespaces") AND ("registry"."registry_present" = 'f' OR "registry"."registry_present" IS NULL) AND "projects"."repository_storage" = $1 AND (1=1) ORDER BY "projects"."last_repository_updated_at" DESC LIMIT $2
14:09:04 rails-background-jobs.1 | 2019-02-21T17:09:04.408Z 80424 TID-ov75yqm5o WARN: ActiveRecord::StatementInvalid: PG::InvalidRecursion: ERROR: recursive query "base_and_descendants" does not have the form non-recursive-term UNION [ALL] recursive-term
14:09:04 rails-background-jobs.1 | LINE 1: ...amespace' AND uploads.model_id IN (WITH RECURSIVE "base_and_...
14:09:04 rails-background-jobs.1 | ^
14:09:04 rails-background-jobs.1 | : SELECT "uploads"."id", "uploads"."uploader" FROM "uploads" WHERE (("uploads"."model_type" = 'Namespace' AND uploads.model_id IN (WITH RECURSIVE "base_and_descendants" AS (SELECT "namespaces".* FROM "namespaces", "base_and_descendants" WHERE "namespaces"."parent_id" = "base_and_descendants"."id") SELECT "id" FROM "base_and_descendants" AS "namespaces") OR "uploads"."model_type" = 'Project' AND uploads.model_id IN (SELECT "projects"."id" FROM "projects" WHERE "projects"."namespace_id" IN (WITH RECURSIVE "base_and_descendants" AS (SELECT "namespaces".* FROM "namespaces", "base_and_descendants" WHERE "namespaces"."parent_id" = "base_and_descendants"."id") SELECT "id" FROM "base_and_descendants" AS "namespaces"))) OR "uploads"."model_type" NOT IN ('Namespace', 'Project')) AND "uploads"."store" = $1 LIMIT $2
Steps to reproduce
- Go to the Geo nodes page
- Click on the edit button for a secondary node
- Change the "Selective synchronization" to "Projects in certain groups"
- Choose a few groups on "Groups to synchronize"
- Save changes
- Check the console for the secondary node
/cc @geo-team