When creating a deployment and linking merge requests, a SQL timeout can prevent the MRs from being linked while the deployment still exists
When creating a deployment and linking merge requests, if we time out after creating the deployment but before/during the linking of merge requests, we may end up with a deployment with no linked merge requests. The easiest solution for this is to run the linking in the same transaction. An alternative is to delegate the linking to a Sidekiq worker. We already use Sidekiq for this when updating an existing deployment, but not when creating a new one (mostly due to how CI is set up to update deployments using a two step approach).
Since linking might be time consuming, I think using Sidekiq for this is best.