Huge Merge Requests are not mergable
Summary
We opened a merge request with a large number of diffs (+60,000 lines, -45.000).
When viewing the MR page, it took a long time, but loaded eventually but the check for mergability did never suceed: 
We tried closing and reopening the MR with no luck, the behaviour persists.
Steps to reproduce
- Create a MR with a lot of changed lines (60,000+)
- Try to merge it
What is the current bug behavior?
Gitlab never shows it is able to merge the MR.
Another interesting thing: We ended up merging this manually with the command line and git told us we had 150,000+ changed lines, and not 60,000 as reported by Gitlab: 
What is the expected correct behavior?
Gitlab is able to merge the MR.
Relevant logs and/or screenshots
Yesterday, we updated to 12.5.2 and are now sometimes getting error 500's when trying to view the MR, sometimes the MR loads eventually but after a long time.
We have this in the logs:
Completed 500 Internal Server Error in 55127ms (ActiveRecord: 15.1ms | Elasticsearch: 0.0ms)
GRPC::DeadlineExceeded (4:Deadline Exceeded):
lib/gitlab/gitaly_client/conflict_files_stitcher.rb:18:in `each'
lib/gitlab/gitaly_client/conflict_files_stitcher.rb:18:in `each'
lib/gitlab/gitaly_client/conflicts_service.rb:29:in `any?'
lib/gitlab/gitaly_client/conflicts_service.rb:29:in `conflicts?'
lib/gitlab/git/repository.rb:1002:in `can_be_merged?'
app/models/repository.rb:489:in `method_missing'
app/services/merge_requests/mergeability_check_service.rb:141:in `can_git_merge?'
app/services/merge_requests/mergeability_check_service.rb:113:in `update_merge_status'
app/services/merge_requests/mergeability_check_service.rb:55:in `check_mergeability'
app/services/merge_requests/mergeability_check_service.rb:43:in `block in execute'
lib/gitlab/exclusive_lease_helpers.rb:29:in `in_lock'
app/services/merge_requests/mergeability_check_service.rb:85:in `in_write_lock'
app/services/merge_requests/mergeability_check_service.rb:37:in `execute'
app/models/merge_request.rb:810:in `check_mergeability'
app/controllers/projects/merge_requests_controller.rb:47:in `show'
app/controllers/application_controller.rb:533:in `block in allow_gitaly_ref_name_caching'
lib/gitlab/gitaly_client.rb:314:in `allow_ref_name_caching'
app/controllers/application_controller.rb:532:in `allow_gitaly_ref_name_caching'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:450:in `set_session_storage'
lib/gitlab/i18n.rb:55:in `with_locale'
lib/gitlab/i18n.rb:61:in `with_user_locale'
app/controllers/application_controller.rb:444:in `set_locale'
lib/gitlab/request_profiler/middleware.rb:17:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:13:in `call'
lib/gitlab/middleware/correlation_id.rb:16:in `block in call'
lib/gitlab/middleware/correlation_id.rb:15:in `call'
lib/gitlab/middleware/multipart.rb:117:in `call'
lib/gitlab/middleware/read_only/controller.rb:48:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/request_context.rb:32:in `call'
config/initializers/fix_local_cache_middleware.rb:9:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:49:in `call'
lib/gitlab/middleware/release_env.rb:12:in `call'
and
{"correlation_id":"eX9P2Yb8At8","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.method":"GetCommitSignatures","grpc.request.deadline":"2019-11-29T09:17:00Z","grpc.request.fullMethod":"/gitaly.CommitService/GetCommitSignatures","grpc.request.glProjectPath":"<company>/<project1>","grpc.request.glRepository":"project-7","grpc.request.repoPath":"<company>/<project1>.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"<company>","grpc.service":"gitaly.CommitService","grpc.start_time":"2019-11-29T09:16:50Z","grpc.time_ms":0.588,"level":"info","msg":"finished streaming call with code OK","peer.address":"@","pid":1937,"span.kind":"server","system":"grpc","time":"2019-11-29T09:16:50Z"}
{"correlation_id":"wh0JJW2vgLa","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.method":"ServerInfo","grpc.request.deadline":"2019-11-29T09:17:02Z","grpc.request.fullMethod":"/gitaly.ServerService/ServerInfo","grpc.service":"gitaly.ServerService","grpc.start_time":"2019-11-29T09:16:52Z","grpc.time_ms":2.53,"level":"info","msg":"finished unary call with code OK","peer.address":"@","pid":1937,"span.kind":"server","system":"grpc","time":"2019-11-29T09:16:52Z"}
{"correlation_id":"DmUZMjnD3i1","error":"rpc error: code = Canceled desc = rpc error: code = Canceled desc = context canceled","grpc.code":"Canceled","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.method":"ListConflictFiles","grpc.request.deadline":"2019-11-29T09:17:04Z","grpc.request.fullMethod":"/gitaly.ConflictsService/ListConflictFiles","grpc.request.glProjectPath":"<company>/<project2>","grpc.request.glRepository":"project-256","grpc.request.repoPath":"<company>/<project2>.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"<company>","grpc.service":"gitaly.ConflictsService","grpc.start_time":"2019-11-29T09:16:09Z","grpc.time_ms":54999.805,"level":"info","msg":"finished streaming call with code Canceled","peer.address":"@","pid":1937,"span.kind":"server","system":"grpc","time":"2019-11-29T09:17:04Z"}
{"correlation_id":"NBEDzAhEbma","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.method":"FindBranch","grpc.request.deadline":"2019-11-29T09:17:50Z","grpc.request.fullMethod":"/gitaly.RefService/FindBranch","grpc.request.glProjectPath":"<company>/<project2>","grpc.request.glRepository":"project-256","grpc.request.repoPath":"<company>/<project2>.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"<company>","grpc.service":"gitaly.RefService","grpc.start_time":"2019-11-29T09:17:20Z","grpc.time_ms":8.716,"level":"info","msg":"finished unary call with code OK","peer.address":"@","pid":1937,"span.kind":"server","system":"grpc","time":"2019-11-29T09:17:20Z"}
{"error":"rpc error: code = DeadlineExceeded desc = context deadline exceeded","level":"warning","msg":"health check failed","time":"2019-11-29T09:17:30Z","worker.name":"gitaly-ruby.0"}
Results of GitLab environment info
Expand for output related to GitLab environment info
(I'll talk to our ops guys to complete this, I have no access to our infrastructure)
Results of GitLab application Check
Expand for output related to the GitLab application check
(I'll talk to our ops guys to complete this, I have no access to our infrastructure)
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)