Consistency scan for missing LFS objects on disk
We saw from https://gitlab.com/gitlab-com/support-forum/issues/1741#note_29028765 that a number of LFS objects were uploaded but may have wound up in local worker paths due to an improper NFS mount.
We should do a scan of our LfsObject
database entries, walking from the most recent to the earlier, to see how many objects we are missing. Something like:
missing = 0
ids = LfsObject.where('created_at >= ?', 1.week.ago).order('created_at DESC').pluck(:id); nil
ids.in_groups_of(1000).each do |lfs_ids|
LfsObject.where(id: lfs_ids).each do |lfs|
missing += 1 unless File.exist?(lfs.file.path)
end
end
puts "Missing LFS objects: #{missing} / #{ids.count}"