-
Stan Hu authored
Previously when a merge request was created, the `after_create` Rails callback would fire the `FetchSourceBranch` Gitaly RPC. However, this call is made inside a database transaction, which may have an idle in transaction timeout. On GitLab.com, this timeout is set to 30 seconds, so any `FetchSourceBranch` calls taking longer than 30 seconds causes the database connection to be terminated quietly. When Rails attempts to make another database write (e.g. writing the metrics), the query fails with a 500 error after the RPC completed, usually because a subsequent query ran into an error. Instead of failing after the idle in transaction, this commit will cause the query to be killed if the total Web request time expires (60 seconds or so). While this isn't ideal, this is better than the alternative because we should never hold open a database transaction for a long Gitaly call. Gitaly team has a few optimizations for `FetchSourceBranch` in the works, but allowing this RPC to run for up to 60 seconds during a Web request is better than the status quo. Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/336657 Changelog: fixed
1349b8cf