Expire project caches once per push instead of once per ref
Previously `ProjectCacheWorker` would be scheduled once per ref, which would generate unnecessary I/O and load on Sidekiq, especially if many tags or branches were pushed at once. `ProjectCacheWorker` would expire three items: 1. Repository size: This only needs to be updated once per push. 2. Commit count: This only needs to be updated if the default branch is updated. 3. Project method caches: This only needs to be updated if the default branch changes, but only if certain files change (e.g. README, CHANGELOG, etc.). Because the third item requires looking at the actual changes in the commit deltas, we schedule one `ProjectCacheWorker` to handle the first two cases, and schedule a separate `ProjectCacheWorker` for the third case if it is needed. As a result, this brings down the number of `ProjectCacheWorker` jobs from N to 2. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/52046
显示
- app/models/repository.rb 6 个添加, 2 个删除app/models/repository.rb
- app/services/git/base_hooks_service.rb 5 个添加, 7 个删除app/services/git/base_hooks_service.rb
- app/workers/post_receive.rb 26 个添加, 4 个删除app/workers/post_receive.rb
- app/workers/project_cache_worker.rb 4 个添加, 2 个删除app/workers/project_cache_worker.rb
- changelogs/unreleased/sh-post-receive-cache-clear-once.yml 5 个添加, 0 个删除changelogs/unreleased/sh-post-receive-cache-clear-once.yml
- lib/gitlab/git_post_receive.rb 11 个添加, 0 个删除lib/gitlab/git_post_receive.rb
- spec/lib/gitlab/git_post_receive_spec.rb 44 个添加, 1 个删除spec/lib/gitlab/git_post_receive_spec.rb
- spec/models/repository_spec.rb 17 个添加, 3 个删除spec/models/repository_spec.rb
- spec/services/git/branch_hooks_service_spec.rb 7 个添加, 3 个删除spec/services/git/branch_hooks_service_spec.rb
- spec/workers/post_receive_spec.rb 66 个添加, 5 个删除spec/workers/post_receive_spec.rb
- spec/workers/project_cache_worker_spec.rb 10 个添加, 0 个删除spec/workers/project_cache_worker_spec.rb
加载中
想要评论请 注册 或 登录