Commit f777f96c authored by Kamil Trzciński's avatar Kamil Trzciński

Acknowledge `build_trace_chunk_spec.rb` doing cross-DB modification

It appears that we introduced bug in `Projects::DestroyService`
that does not clean `build_trace_chunks`, thus we cannot fix
`build_trace_chunk_spec.rb` at this moment.
parent 1e83055e
...@@ -12,9 +12,7 @@ module Ci ...@@ -12,9 +12,7 @@ module Ci
# Ci::Pipeline#destroy triggers `use_fast_destroy :job_artifacts` and # Ci::Pipeline#destroy triggers `use_fast_destroy :job_artifacts` and
# ci_builds has ON DELETE CASCADE to ci_pipelines. The pipeline, the builds, # ci_builds has ON DELETE CASCADE to ci_pipelines. The pipeline, the builds,
# job and pipeline artifacts all get destroyed here. # job and pipeline artifacts all get destroyed here.
::Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.allow_cross_database_modification_within_transaction(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/345664') do pipeline.reset.destroy!
pipeline.reset.destroy!
end
ServiceResponse.success(message: 'Pipeline not found') ServiceResponse.success(message: 'Pipeline not found')
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
......
...@@ -49,9 +49,9 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git ...@@ -49,9 +49,9 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git
end end
context 'FastDestroyAll' do context 'FastDestroyAll' do
let(:parent) { create(:project) } let(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: parent) } let(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, :running, :trace_live, pipeline: pipeline, project: parent) } let!(:build) { create(:ci_build, :running, :trace_live, pipeline: pipeline, project: project) }
let(:subjects) { build.trace_chunks } let(:subjects) { build.trace_chunks }
describe 'Forbid #destroy and #destroy_all' do describe 'Forbid #destroy and #destroy_all' do
...@@ -84,7 +84,13 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git ...@@ -84,7 +84,13 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git
expect(external_data_counter).to be > 0 expect(external_data_counter).to be > 0
expect(subjects.count).to be > 0 expect(subjects.count).to be > 0
expect { parent.destroy! }.not_to raise_error ::Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.allow_cross_database_modification_within_transaction(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/350185') do
# This should use to prevent cross-DB modification
# but due to https://gitlab.com/gitlab-org/gitlab/-/issues/350185
# the build trace chunks are not destroyed by Projects::DestroyService
# Change to: expect { Projects::DestroyService.new(project, project.owner).execute }.to eq(true)
expect { project.destroy! }.not_to raise_error
end
expect(subjects.count).to eq(0) expect(subjects.count).to eq(0)
expect(external_data_counter).to eq(0) expect(external_data_counter).to eq(0)
...@@ -830,7 +836,7 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git ...@@ -830,7 +836,7 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git
expect(described_class.count).to eq(3) expect(described_class.count).to eq(3)
subject expect(subject).to be_truthy
expect(described_class.count).to eq(0) expect(described_class.count).to eq(0)
...@@ -852,7 +858,13 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git ...@@ -852,7 +858,13 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git
context 'when project is destroyed' do context 'when project is destroyed' do
let(:subject) do let(:subject) do
project.destroy! ::Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.allow_cross_database_modification_within_transaction(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/350185') do
# This should use to prevent cross-DB modification
# but due to https://gitlab.com/gitlab-org/gitlab/-/issues/350185
# the build trace chunks are not destroyed by Projects::DestroyService
# Change to: Projects::DestroyService.new(project, project.owner).execute
project.destroy!
end
end end
it_behaves_like 'deletes all build_trace_chunk and data in redis' it_behaves_like 'deletes all build_trace_chunk and data in redis'
......
- "./spec/models/ci/build_trace_chunk_spec.rb"
- "./spec/models/ci/job_artifact_spec.rb" - "./spec/models/ci/job_artifact_spec.rb"
- "./spec/services/ci/retry_build_service_spec.rb" - "./spec/services/ci/retry_build_service_spec.rb"
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