fix: stream attachment handling in workers (#12870)
We’ve been watching Sidekiq workers climb from ~600 MB at boot to 1.4–1.5 GB after an hour whenever attachment-heavy jobs run. This PR is an experiment to curb that growth by streaming attachments instead of loading the whole blob into Ruby: reply-mailer inline attachments, Telegram uploads, and audio transcriptions now read/write in chunks. If this keeps RSS stable in production we’ll keep it; otherwise we’ll roll it back and keep digging
This commit is contained in:
@@ -15,8 +15,11 @@ RSpec.describe DataImportJob do
|
||||
|
||||
describe 'retrying the job' do
|
||||
context 'when ActiveStorage::FileNotFoundError is raised' do
|
||||
let(:import_file_double) { instance_double(ActiveStorage::Blob) }
|
||||
|
||||
before do
|
||||
allow(data_import.import_file).to receive(:download).and_raise(ActiveStorage::FileNotFoundError)
|
||||
allow(data_import).to receive(:import_file).and_return(import_file_double)
|
||||
allow(import_file_double).to receive(:open).and_raise(ActiveStorage::FileNotFoundError)
|
||||
end
|
||||
|
||||
it 'retries the job' do
|
||||
@@ -158,7 +161,9 @@ RSpec.describe DataImportJob do
|
||||
end
|
||||
|
||||
before do
|
||||
allow(data_import.import_file).to receive(:download).and_return(invalid_csv_content)
|
||||
import_file_double = instance_double(ActiveStorage::Blob)
|
||||
allow(data_import).to receive(:import_file).and_return(import_file_double)
|
||||
allow(import_file_double).to receive(:open).and_yield(StringIO.new(invalid_csv_content))
|
||||
end
|
||||
|
||||
it 'does not import any data and handles the MalformedCSVError' do
|
||||
|
||||
Reference in New Issue
Block a user