Intermittent Issue with Diff View Not Updating on New Commits in GitLab
Summary
We have encountered an infrequent issue on our self-hosted GitLab service, which manages an extremely large project with several million commits over a decade. In less than 1% of cases, the Diff view continues to display the previous state even after a new commit has been pushed. Refreshing the page doesn't help to fix the issue. We have to manually switch to a different commit view and then switch back to the "latest" commit to have the diff view refreshed.
Steps to reproduce
There is no reliable way to reproduce the issue since it only has a small chance to happen.
What is the current bug behavior?
We've observed that this issue only occurs when a user deselects the "show one file at a time" option. In this scenario, the front end simultaneously sends two requests to obtain the diffs metadata in "diffs_metadata.json" and the actual diffs data in "diffs_batch.json". The discrepancy lies in the fact that "diffs_metadata.json" includes all commits, encompassing the most recently added one, while "diffs_batch.json" continues to display detailed diff data related to the previous commit.
Based on our observations, it appears there could be two contributing factors:
-
A potential race condition might exist when generating "diffs_batch.json" data. It seems the data is populated before the appropriate diffs flags have been set, resulting in the retrieval of the previous commit's diffs.
-
It also appears that the "diffs_batch.json" results are cached in some way. Despite refreshing the page, even after several minutes when backend data should have been updated, the front end view remains unchanged. This persistent caching might be preventing the front end view from displaying the most recent data.
What is the expected correct behavior?
When the user chooses to see all files' changes in the diff view (unchecks the "show one file at a time option"), the default "latest" diff view should show the correct latest diff view.
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Debian 10 Proxy: no Current User: git Using RVM: no Ruby Version: 3.0.6p216 Gem Version: 3.4.14 Bundler Version:2.4.16 Rake Version: 13.0.6 Redis Version: 7.0.12 Sidekiq Version:6.5.7 Go Version: unknown GitLab information Version: 16.2.4-ee Revision: 9544e5451d7 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 13.11 URL: https://gitlab.redacted.com HTTP Clone URL: https://gitlab.redacted.com/some-group/some-project.git SSH Clone URL: git@gitlab.redacted.com:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: kerberos GitLab Shell Version: 14.23.0 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell