Linking merge requests to deployments may lead to duplicate key errors when changing the status back and forth to success
The following discussion from !18755 (merged) should be addressed:
-
@yorickpeterse started a discussion: Currently we can run into a bug:
When changing the status of a deployment to success, we link the merge requests. If we then change the status of that same deployment to failed (or something else), then back to success, we'd try to link merge requests again. Since the merge requests already exists, this will produce a duplicate key error.
For now I think this is not an issue since this case is unlikely to happen. A simple solution to this problem would be not allowing to change the status once it becomes "success". The alternative is to remove rows in the linked table when changing away from "success", but this may allow for abuse: doing this often will create many dead tuples, which could impact the database in a negative way.