500 error because of large sized diffs within a commit
Created by: seanhussey
Hello,
Here's the log entry:
Processing by CommitsController#show as HTML
Parameters: {"project_id"=>"our_project", "id"=>"git_sha_here"}
Rendered commits/_commit_box.html.haml (9.5ms)
Rendered commits/huge_commit.html.haml within layouts/project (12.0ms)
Completed 500 Internal Server Error in 60182ms
ActionView::Template::Error (undefined method `parents' for nil:NilClass):
1: .commit-box{class: @commit.parents.count > 1 ? "merge-commit" : ""}
2: .commit-head
3: .right
4: - if @notes_count > 0
app/views/commits/_commit_box.html.haml:1:in `_app_views_commits__commit_box_html_haml__4047047422410992973_66367180'
app/views/commits/huge_commit.html.haml:1:in `_app_views_commits_huge_commit_html_haml___4268135454055904838_66401780'
app/controllers/commits_controller.rb:44:in `rescue in show'
app/controllers/commits_controller.rb:29:in `show'
We increased the timeout to 60 seconds, but now it just takes that long to get the 500 back. The diff in question is about 660K, well within the 5M limit.
We can see the commit in the commit history, we just can't get the details.
This is in Gitlab 2.7.
Upon further investigation, it seems things die in CommitLoad#execute on this line:
result[:suppress_diff] = true if commit.diffs.size > 200 && !params[:force_show_diff]
I've confirmed it's commit.diffs that's causing the problem. Here's the (sanitized) git diff --stat for the commit:
$ git diff 75d23aff84af2f6cb84309fee7511ebf11de043e --stat
file_1.rb | 3 +-
file_2.rb | 3 +-
file_3.rb | 6 +-
file_4.rb | 14 +-
file_5.rb | 2 +-
db/test_structure.sql | 12843 ++++++++++++++++++++++++++++++++++------------------
file_6.rb | 51 -
file_7.rb | 38 +
file_8.rb | 65 -
9 files changed, 8499 insertions(+), 4526 deletions(-)
So it's not the size of the commit that's too big, but the size of some of the individual diffs. There were 8 "diffs" in this commit according to GitLab, and one of them, output as text, was 260K. If I increase timeout to something huge, this will work, but I'd rather avoid that.