Cannot commit to fork from main project if fork is behind
Summary
When a user attempts to commit a change made via the edit button on a main project, and their fork is a few commits behind, the commit will fail with a message Someone edited the file the same time you did. Please check out the file and make sure your changes will not unintentionally remove theirs.
This will happen regardless of whether the user is the only one on that project. Note that this does not happen if the WebIDE button is used - in that case, the file is opened directly in the forked project to be edited.
This issue started after an upgrade to v14.2.5. Customer did not see this happening on v13.9.5.
Steps to reproduce
- Have a project (e.g. mainproject) that a user does not have write access to
- The user creates a fork of this project
- Have main project be a few commits ahead of the user's fork
- Go to main project, open a file -> Edit
- Click commit button which says
A new branch will be created in your fork and a new merge request will be started.
- See error message
Someone edited the file the same time you did. Please...
What is the current bug behavior?
Commit fails (with an incorrect message?).
What is the expected correct behavior?
Commit is successful OR more appropriate message regarding fork being too far behind.
Relevant logs and/or screenshots
CommitError.log (Doesn't seem to show error?):
/var/log/gitlab/gitlab-rails/production_json.log:{"method":"PUT","path":"/forktest/main/-/update/main/README.md","format":"html","controller":"Projects::BlobController","action":"update","status":200,"time":"2021-11-01T05:43:53.261Z","params":[{"key":"_method","value":"put"},{"key":"authenticity_token","value":"[FILTERED]"},{"key":"file_path","value":"README.md"},{"key":"commit_message","value":"Update README.md"},{"key":"branch_name","value":"mrstrickland-main-patch-09626"},{"key":"create_merge_request","value":"1"},{"key":"original_branch","value":"main"},{"key":"last_commit_sha","value":"ebe991a0028b62bd23f0c459d39d8cc4aea6a6aa"},{"key":"content","value":"[FILTERED]"},{"key":"from_merge_request_iid","value":""},{"key":"namespace_id","value":"forktest"},{"key":"project_id","value":"main"},{"key":"id","value":"main/README.md"}],"remote_ip":"43.243.56.129","user_id":33,"username":"mrstrickland","ua":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36","correlation_id":"01FKD0D0FA64DPYM5AN5SEW88F","meta.user":"mrstrickland","meta.project":"forktest/main","meta.root_namespace":"forktest","meta.caller_id":"Projects::BlobController#update","meta.remote_ip":"43.243.56.129","meta.feature_category":"source_code_management","meta.client_id":"user/33","gitaly_calls":4,"gitaly_duration_s":0.019146,"redis_calls":42,"redis_duration_s":0.012599,"redis_read_bytes":8395,"redis_write_bytes":4603,"redis_cache_calls":41,"redis_cache_duration_s":0.01192,"redis_cache_read_bytes":8174,"redis_cache_write_bytes":3778,"redis_shared_state_calls":1,"redis_shared_state_duration_s":0.000679,"redis_shared_state_read_bytes":221,"redis_shared_state_write_bytes":825,"db_count":44,"db_write_count":0,"db_cached_count":9,"cpu_s":1.06143,"mem_objects":753856,"mem_bytes":77490938,"mem_mallocs":268994,"mem_total_bytes":107645178,"pid":543927,"queue_duration_s":0.034145,"db_duration_s":0.09715,"view_duration_s":0.73386,"duration_s":1.12528}
/var/log/gitlab/gitlab-workhorse/current:{"content_type":"text/html; charset=utf-8","correlation_id":"01FKD0D0FA64DPYM5AN5SEW88F","duration_ms":1229,"host":"gitlab.agounder.com","level":"info","method":"POST","msg":"access","proto":"HTTP/1.1","referrer":"https://gitlab.agounder.com/forktest/main/-/update/main/README.md","remote_addr":"43.243.56.129:0","remote_ip":"43.243.56.129","route":"","status":200,"system":"http","time":"2021-11-01T05:43:53Z","ttfb_ms":1226,"uri":"/forktest/main/-/update/main/README.md","user_agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36","written_bytes":157327}
/var/log/gitlab/gitaly/current:{"correlation_id":"01FKD0D0FA64DPYM5AN5SEW88F","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.meta.deadline_type":"regular","grpc.meta.method_type":"unary","grpc.method":"FindCommit","grpc.request.deadline":"2021-11-01T05:44:22.021Z","grpc.request.fullMethod":"/gitaly.CommitService/FindCommit","grpc.request.glProjectPath":"forktest/main","grpc.request.glRepository":"project-7258","grpc.request.repoPath":"@hashed/b2/bf/b2bf50ecada62994533dcc3197242102a5f1e20bc8acc45f904eb0a2004dfb1f.git","grpc.request.repoStorage":"default","grpc.service":"gitaly.CommitService","grpc.start_time":"2021-11-01T05:43:52.421Z","grpc.time_ms":2.571,"level":"info","msg":"finished unary call with code OK","peer.address":"@","pid":2769221,"remote_ip":"43.243.56.129","span.kind":"server","system":"grpc","time":"2021-11-01T05:43:52.424Z","username":"mrstrickland"}
/var/log/gitlab/gitaly/current:{"correlation_id":"01FKD0D0FA64DPYM5AN5SEW88F","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.meta.deadline_type":"regular","grpc.meta.method_type":"server_stream","grpc.method":"TreeEntry","grpc.request.deadline":"2021-11-01T05:44:22.026Z","grpc.request.fullMethod":"/gitaly.CommitService/TreeEntry","grpc.request.glProjectPath":"forktest/main","grpc.request.glRepository":"project-7258","grpc.request.repoPath":"@hashed/b2/bf/b2bf50ecada62994533dcc3197242102a5f1e20bc8acc45f904eb0a2004dfb1f.git","grpc.request.repoStorage":"default","grpc.service":"gitaly.CommitService","grpc.start_time":"2021-11-01T05:43:52.426Z","grpc.time_ms":1.026,"level":"info","msg":"finished streaming call with code OK","peer.address":"@","pid":2769221,"remote_ip":"43.243.56.129","span.kind":"server","system":"grpc","time":"2021-11-01T05:43:52.427Z","username":"mrstrickland"}
/var/log/gitlab/gitaly/current:{"correlation_id":"01FKD0D0FA64DPYM5AN5SEW88F","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.meta.deadline_type":"regular","grpc.meta.method_type":"server_stream","grpc.method":"FindCommits","grpc.request.deadline":"2021-11-01T05:44:22.031Z","grpc.request.fullMethod":"/gitaly.CommitService/FindCommits","grpc.request.glProjectPath":"forktest/main","grpc.request.glRepository":"project-7258","grpc.request.repoPath":"@hashed/b2/bf/b2bf50ecada62994533dcc3197242102a5f1e20bc8acc45f904eb0a2004dfb1f.git","grpc.request.repoStorage":"default","grpc.service":"gitaly.CommitService","grpc.start_time":"2021-11-01T05:43:52.431Z","grpc.time_ms":2.345,"level":"info","msg":"finished streaming call with code OK","peer.address":"@","pid":2769221,"remote_ip":"43.243.56.129","span.kind":"server","system":"grpc","time":"2021-11-01T05:43:52.433Z","username":"mrstrickland"}
/var/log/gitlab/gitaly/current:{"correlation_id":"01FKD0D0FA64DPYM5AN5SEW88F","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.meta.deadline_type":"regular","grpc.meta.method_type":"server_stream","grpc.method":"FindCommits","grpc.request.deadline":"2021-11-01T05:44:22.079Z","grpc.request.fullMethod":"/gitaly.CommitService/FindCommits","grpc.request.glProjectPath":"mrstrickland/main","grpc.request.glRepository":"project-7260","grpc.request.repoPath":"@hashed/79/8b/798bf980fe3b447993defabab766f08ea559cef763004067554516f57f48ffaa.git","grpc.request.repoStorage":"default","grpc.service":"gitaly.CommitService","grpc.start_time":"2021-11-01T05:43:52.479Z","grpc.time_ms":4.129,"level":"info","msg":"finished streaming call with code OK","peer.address":"@","pid":2769221,"remote_ip":"43.243.56.129","span.kind":"server","system":"grpc","time":"2021-11-01T05:43:52.484Z","username":"mrstrickland"}
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Ubuntu 20.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.7.2p137 Gem Version: 3.1.4 Bundler Version:2.1.4 Rake Version: 13.0.6 Redis Version: 6.0.14 Git Version: 2.32.0 Sidekiq Version:5.2.9 Go Version: unknown GitLab information Version: 14.2.5-ee Revision: 72c1da0383a Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 12.6 URL: https://gitlab.agounder.com HTTP Clone URL: https://gitlab.agounder.com/some-group/some-project.git SSH Clone URL: git@gitlab.agounder.com:some-group/some-project.git Elasticsearch: no Geo: yes Geo node: Primary Using LDAP: yes Using Omniauth: yes Omniauth Providers: saml, azure_activedirectory_v2, azure_activedirectory_v2, group_saml, crowd GitLab Shell Version: 13.19.1 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git