Skip to content

500 error when I create a pull request in which some big text files are committed.

Summary

When I create a pull request in which I commit some very large text files, the gitlab returns 500 error.

Steps to reproduce

  1. I have two branches, A001 and master.
  2. In branch A001, we have made many changes, including a very large ( > 200kb ) .json file.
  3. Commit a pull request from A001 to master.
  4. gitlab return 500.

What is the current bug behavior?

It return 500 error.

What is the expected correct behavior?

It runs well, create a pull request successfully.

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's very hard to read otherwise.)

I check the log file /var/log/gitlab/gitlab-rails/production.log. Some important lines as below:

Started GET "/profile/keys" for 119.137.52.39 at 2018-07-24 16:04:25 +0800
Processing by Profiles::KeysController#index as HTML
Completed 200 OK in 36ms (Views: 27.4ms | ActiveRecord: 3.1ms)
Started POST "/axd/axd-app/merge_requests" for 163.125.152.247 at 2018-07-24 16:04:26 +0800
Processing by Projects::MergeRequests::CreationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "merge_request"=>{"title"=>"A001", "description"=>"", "assignee_id"=>"10", "label_ids"=>[""], "force_remove_source_branch"=>"0", "lock_version"=>"", "source_project_id"=>"7", "source_branch"=>"A001", "target_project_id"=>"7", "target_branch"=>"master"}, "namespace_id"=>"axd", "project_id"=>"axd-app"}
Completed 500 Internal Server Error in 369ms (ActiveRecord: 43.8ms)

ActiveRecord::StatementInvalid (Mysql2::Error: Data too long for column 'diff' at row 126:     INSERT INTO merge_request_diff_files (`diff`, `new_path`, `old_path`, `a_mode`, `b_mode`, `new_file`, `renamed_file`, `deleted_file`, `too_large`, `binary`, `merge_request_diff_id`, `relative_order`)

...
...
(many many characters, which refer to the value of `diff`)
...
...

config/initializers/connection_fix.rb:20:in `execute'
  lib/gitlab/database.rb:149:in `bulk_insert'
  app/models/merge_request_diff.rb:225:in `create_merge_request_diff_files'
  app/models/merge_request_diff.rb:259:in `save_diffs'
  app/models/merge_request_diff.rb:54:in `save_git_content'
  app/models/merge_request.rb:530:in `block in create_merge_request_diff'
  lib/gitlab/gitaly_client.rb:297:in `allow_n_plus_1_calls'
  app/models/merge_request.rb:529:in `create_merge_request_diff'
  app/models/merge_request.rb:522:in `ensure_merge_request_diff'
  app/services/issuable_base_service.rb:131:in `block in create_issuable'
  app/services/issuable_base_service.rb:130:in `create_issuable'
  app/services/issuable_base_service.rb:150:in `create'
  app/services/merge_requests/create_service.rb:34:in `create'
  app/services/merge_requests/create_service.rb:12:in `execute'
  app/controllers/projects/merge_requests/creations_controller.rb:21:in `create'
  lib/gitlab/i18n.rb:50:in `with_locale'
  lib/gitlab/i18n.rb:56:in `with_user_locale'
  app/controllers/application_controller.rb:330:in `set_locale'
  lib/gitlab/middleware/multipart.rb:95:in `call'
  lib/gitlab/request_profiler/middleware.rb:14:in `call'
  lib/gitlab/middleware/go.rb:17:in `call'
  lib/gitlab/etag_caching/middleware.rb:11:in `call'
  lib/gitlab/middleware/read_only/controller.rb:28:in `call'
  lib/gitlab/middleware/read_only.rb:16:in `call'
  lib/gitlab/request_context.rb:18:in `call'
  lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
  lib/gitlab/middleware/release_env.rb:10:in `call'

Output of checks

no

Results of GitLab environment info

System information
System:        CentOS 7.2.1511
Current User:    git
Using RVM:    no
Ruby Version:    2.3.6p384
Gem Version:    2.6.13
Bundler Version:1.13.7
Rake Version:    12.3.0
Redis Version:    3.2.11
Git Version:    2.14.4
Sidekiq Version:5.0.5
Go Version:    unknown

GitLab information
Version:    10.6.6
Revision:    16f9faa
Directory:    /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:    mysql2
URL:        http://47.106.189.230:7000
HTTP Clone URL:    http://47.106.189.230:7000/some-group/some-project.git
SSH Clone URL:    git@47.106.189.230:some-group/some-project.git
Using LDAP:    no
Using Omniauth:    no

GitLab Shell
Version:    6.0.4
Repository storage paths:
- default:     /mnt/data/git/repositories
Hooks:        /opt/gitlab/embedded/service/gitlab-shell/hooks
Git:        /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Checking GitLab Shell ...

GitLab Shell version >= 6.0.4 ? ... OK (6.0.4)
Repo base directory exists?
default... yes
Repo storage directories are symlinks?
default... no
Repo paths owned by git:root, or git:git?
default... yes
Repo paths access is drwxrws---?
default... yes
hooks directories in repos are links: ...
2/1 ... ok
4/2 ... ok
4/3 ... ok
4/4 ... ok
4/7 ... ok
4/8 ... ok
4/10 ... ok
4/13 ... ok
4/14 ... ok
4/15 ... repository is empty
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Redis available via internal API: OK

Access to /var/opt/gitlab/.ssh/authorized_keys: OK
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Reply by email is disabled in config/gitlab.yml
Checking LDAP ...

LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab ...

Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... yes
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Projects have namespace: ...
2/1 ... yes
4/2 ... yes
4/3 ... yes
4/4 ... yes
4/7 ... yes
4/8 ... yes
4/10 ... yes
4/13 ... yes
4/14 ... yes
4/15 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.3.5 ? ... yes (2.3.6)
Git version >= 2.9.5 ? ... yes (2.14.4)
Git user has default SSH configuration? ... no
  Try fixing it:
  mkdir ~/gitlab-check-backup-1532490238
  sudo mv /var/opt/gitlab/.ssh/id_rsa.pub ~/gitlab-check-backup-1532490238
  sudo mv /var/opt/gitlab/.ssh/id_rsa ~/gitlab-check-backup-1532490238
  For more information see:
  doc/ssh/README.md in section "SSH on the GitLab server"
  Please fix the error above and rerun the checks.
Active users: ... 12

Checking GitLab ... Finished

Possible fixes

Maybe we can turn strict mode off of MySQL?