mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-26 06:43:42 +01:00
Fix infinite loop in AccountsStatusesCleanupScheduler (#24840)
This commit is contained in:
parent
f95125bd04
commit
c3c7d59072
2 changed files with 15 additions and 0 deletions
|
@ -79,6 +79,7 @@ class Scheduler::AccountsStatusesCleanupScheduler
|
||||||
# and start back after the last processed account otherwise
|
# and start back after the last processed account otherwise
|
||||||
break if budget.zero? || (num_processed_accounts.zero? && !full_iteration)
|
break if budget.zero? || (num_processed_accounts.zero? && !full_iteration)
|
||||||
|
|
||||||
|
full_iteration = false unless first_iteration
|
||||||
first_iteration = false
|
first_iteration = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -143,6 +143,20 @@ describe Scheduler::AccountsStatusesCleanupScheduler do
|
||||||
expect { subject.perform }.to change { Status.count }.by(-30)
|
expect { subject.perform }.to change { Status.count }.by(-30)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when there is no work to be done' do
|
||||||
|
let(:process_set_stub) { [{ 'concurrency' => 400, 'queues' => %w(push default) }] }
|
||||||
|
|
||||||
|
before do
|
||||||
|
stub_const 'Scheduler::AccountsStatusesCleanupScheduler::MAX_BUDGET', 400
|
||||||
|
subject.perform
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not get stuck' do
|
||||||
|
expect(subject.compute_budget).to eq(400)
|
||||||
|
expect { subject.perform }.to_not change { Status.count }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue