Skip to content
代码片段 群组 项目
未验证 提交 1349b8cf 编辑于 作者: Stan Hu's avatar Stan Hu
浏览文件

Avoid idling in transaction when fetching source for merge requests

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
上级 124f7b9d
No related branches found
No related tags found
加载中
加载中
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册