Detect the source of new duplicates LFS objects projects

Context

Now that the Background migration to deduplicate LFS object ... (!154323 - merged) is finished in production and Add advisory lock to ensure uniqueness of LFS o... (!159264 - merged) is in place, there should not be new lfs_objects_projects duplicate records saved in the database.

However, there are a few new duplicates detected, potentially due to a bulk insert or raw insert in our codebase.

Some places to investigate:

  1. Projects::MoveLfsObjectsProjectsService#move_lfs_objects_projects. It uses update_all so it bypasses the model validations.
  2. Projects::LfsPointers::LfsLinkService#link_existing_lfs_objects. It uses ApplicationRecord.legacy_bulk_insert to link LFS objects projects to a fork -> This is probably the problem since the records found do not have created_at or updated_at timestamps.

Problem to solve

Edited by Javiera Tapia