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

Merge branch 'fix/gb/fix-chunks-read-race' into 'master'

Resolve live trace read race condition using a retry

See merge request gitlab-org/gitlab!44988
parents 6fbd70d0 af301efb
......@@ -80,11 +80,9 @@ module Gitlab
job.trace_chunks.any? || current_path.present? || old_trace.present?
end
def read(should_retry: true, &block)
def read(&block)
read_stream(&block)
rescue Errno::ENOENT
raise unless should_retry
rescue Errno::ENOENT, ChunkedIO::FailedToGetChunkError
job.reset
read_stream(&block)
end
......
......@@ -33,6 +33,16 @@ RSpec.describe Gitlab::Ci::Trace, :clean_gitlab_redis_shared_state, factory_defa
expect(artifact2.job.trace.raw).to eq(test_data)
end
it 'reloads the trace in case of a chunk error' do
chunk_error = described_class::ChunkedIO::FailedToGetChunkError
allow_any_instance_of(described_class::Stream)
.to receive(:raw).and_raise(chunk_error)
expect(build).to receive(:reset).and_return(build)
expect { trace.raw }.to raise_error(chunk_error)
end
end
context 'when live trace feature is disabled' do
......
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