Skip to content

Draft: Add advisory lock to LFS objects projects

What does this MR do and why?

We want to deduplicate the lfs_objects_projects table by lfs_object_id, project_id, and repository_type. To achieve this, we have !154323, which creates a batched background migration. However, we should should also avoid creating new duplicates in the lfs_objects_projects table during the deduplicate migration.

This MR introduces an explicit locking mechanism (advisory lock) in the lfs_object_project model, which is executed on every record creation (except bulk insert, which is not likely the source for duplications). This advisory lock will be taken by a new callback and affect the 3 column values if they are present. Also, this callback should be behind an FF to be sure about its effectiveness and behavior.

Context: !154323 (comment 1994629812)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Related to #199909

Merge request reports