Geo: LFS not being synced
In b89457d9 we refactored some code and lost one important bit from the LFS query: b89457d9
When
def fdw_find_unsynced(except_file_ids:)
fdw_all.joins("LEFT OUTER JOIN file_registry
ON file_registry.file_id = #{fdw_table}.id
AND file_registry.file_type = 'lfs'")
.geo_syncable
.where(file_registry: { id: nil })
.where.not(id: except_file_ids)
become:
def lfs_objects_unsynced(except_file_ids:)
fdw_geo_node
.lfs_objects
.syncable
.missing_file_registry
.id_not_in(except_file_ids)
The query lost the join condition that matches file_type = 'lfs'
. This makes the LFS sync stop adding new items to be synchronized.
I'm flagging this as a regression from %12.1 but there is a chance this affected even previous versions (last 11.x). In %12.1 we removed the legacy queries, which made this affect any customer from that version ahead.
current code from lfs_objects_unsynced
results in the following query:
SELECT "gitlab_secondary"."lfs_objects"."id"
FROM "gitlab_secondary"."lfs_objects"
LEFT OUTER JOIN "file_registry" ON "gitlab_secondary"."lfs_objects"."id" = "file_registry"."file_id"
WHERE ("gitlab_secondary"."lfs_objects"."file_store" = 1 OR "gitlab_secondary"."lfs_objects"."file_store" IS NULL)
AND "file_registry"."id" IS NULL
LIMIT 25;
what we should be doing instead:
SELECT "gitlab_secondary"."lfs_objects"."id"
FROM "gitlab_secondary"."lfs_objects"
LEFT OUTER JOIN "file_registry" ON ("gitlab_secondary"."lfs_objects"."id" = "file_registry"."file_id" AND
file_registry.file_type = 'lfs')
WHERE ("gitlab_secondary"."lfs_objects"."file_store" = 1 OR "gitlab_secondary"."lfs_objects"."file_store" IS NULL)
AND "file_registry"."id" IS NULL
LIMIT 25;
Edited by Gabriel Mazetto