Commenting on a merge request timeouts sometimes

It sometimes happens that posting comments on merge requests timeouts and throws 500 error.

See https://sentry.gitlap.com/gitlab/gitlabcom/issues/37766/

It often happens when I push new commits to a merge request and immediately try to post a comment. It might be related to updating head_pipeline_id in merge request.

We also have belongs_to :noteable, polymorphic: true, touch: true which bumps merge request's updated_at when someone posts a new comment.

We also have optimistic locking lock_version in merge_requests.

These things can overlap and produce query timeouts. It might be a good idea to investigate this.

/cc @smcgivern @ayufan