Commit 529a7948 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add feature flag to disable db-writes on git-http

This adds the disable_git_http_fetch_writes feature flag. It allows
diabling some non-essential writes during git fetches hopefully
improving the apdex of some of the git endpoints.
parent 7d25a6e6
...@@ -78,6 +78,8 @@ module Repositories ...@@ -78,6 +78,8 @@ module Repositories
def update_fetch_statistics def update_fetch_statistics
return unless project return unless project
return if Gitlab::Database.read_only? return if Gitlab::Database.read_only?
return if Feature.enabled?(:disable_git_http_fetch_writes)
return unless repo_type.project? return unless repo_type.project?
OnboardingProgressService.new(project.namespace).execute(action: :git_read) OnboardingProgressService.new(project.namespace).execute(action: :git_read)
......
---
name: disable_git_http_fetch_writes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54322
rollout_issue_url: https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/883
milestone: '13.9'
type: development
group: group::source code
default_enabled: false
...@@ -36,7 +36,7 @@ RSpec.describe Repositories::GitHttpController do ...@@ -36,7 +36,7 @@ RSpec.describe Repositories::GitHttpController do
context 'when project_statistics_sync feature flag is disabled' do context 'when project_statistics_sync feature flag is disabled' do
before do before do
stub_feature_flags(project_statistics_sync: false) stub_feature_flags(project_statistics_sync: false, disable_git_http_fetch_writes: false)
end end
it 'updates project statistics async for projects' do it 'updates project statistics async for projects' do
...@@ -47,6 +47,8 @@ RSpec.describe Repositories::GitHttpController do ...@@ -47,6 +47,8 @@ RSpec.describe Repositories::GitHttpController do
end end
it 'updates project statistics sync for projects' do it 'updates project statistics sync for projects' do
stub_feature_flags(disable_git_http_fetch_writes: false)
expect { send_request }.to change { expect { send_request }.to change {
Projects::DailyStatisticsFinder.new(container).total_fetch_count Projects::DailyStatisticsFinder.new(container).total_fetch_count
}.from(0).to(1) }.from(0).to(1)
...@@ -56,6 +58,29 @@ RSpec.describe Repositories::GitHttpController do ...@@ -56,6 +58,29 @@ RSpec.describe Repositories::GitHttpController do
let(:namespace) { project.namespace } let(:namespace) { project.namespace }
subject { send_request } subject { send_request }
before do
stub_feature_flags(disable_git_http_fetch_writes: false)
end
end
context 'when disable_git_http_fetch_writes is enabled' do
before do
stub_feature_flags(disable_git_http_fetch_writes: true)
end
it 'does not increment statistics' do
expect(Projects::FetchStatisticsIncrementService).not_to receive(:new)
expect(ProjectDailyStatisticsWorker).not_to receive(:perform_async)
send_request
end
it 'does not record onboarding progress' do
expect(OnboardingProgressService).not_to receive(:new)
send_request
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment