Unlinked LFS files not removed

Problem to solve

In our company we had problem, that repository is being consume a lot of disk space. We figured out that it’s because binary objects stored in repository. These objects were stored via LFS in the repository.

Via git-filter-repo, commit-map file and push –force cleaned repo, we were able to reduce repo size from ~50GB to the 20GB, so far so good.

But, our repo itself takes ~2,5GB, rest in the LFS storage.

image

And now the problem is, that our LFS in this repo should be empty, because all files were removed from working-tree and history.

See result from git lfs ls-files:

image

sudo gitlab-rake gitlab:cleanup:orphan_lfs_files

and

sudo gitlab-rake gitlab:cleanup:orphan_lfs_file_references PROJECT_ID=“26”

did no remove anything.

By the query:

SELECT p.name AS project, COUNT(l.id) AS object_count, ROUND(SUM(l.size)/1024.0/1024.0, 2) AS total_mb, MIN(l.created_at) AS oldest, MAX(l.created_at) AS newest FROM lfs_objects l JOIN lfs_objects_projects lp ON lp.lfs_object_id = l.id JOIN projects p ON p.id = lp.project_id WHERE p.id = 26 GROUP BY p.name;

I checked that in database I have 119 objects:

And actually here I do not understand it well, but chatGPT told me, that probably it’s mean that they are unreferenced objects.

From the query:

SELECT lfs_objects.oid, ROUND( lfs_objects.size / 1024.0 / 1024.0, 2 ) as size_mb,

lfs_objects.updated_at

FROM lfs_objects JOIN lfs_objects_projects ON lfs_objects.id = lfs_objects_projects.lfs_object_id WHERE lfs_objects_projects.project_id = 26 ORDER BY lfs_objects.size DESC LIMIT 70;

I checked first OID

by these commands and I understood that objects are unreferenced.

image

My question is, how Am I able to remove these?

And did I do something wrong?

Versions

I have Self-managed gitlab in version 17.8.1