Unverified Commit a32cac06 authored by Benjamin Neff's avatar Benjamin Neff Committed by Dennis Schubert

Retry Contact messages 20 time (about two weeks)

closes #7705
parent b9787cc6
......@@ -4,6 +4,8 @@
* Work on the data downloads: Fixed general layout of buttons, added a timestamp and implemented auto-deletion of old exports [#7684](https://github.com/diaspora/diaspora/pull/7684)
* Increase Twitter character limit to 280 [#7694](https://github.com/diaspora/diaspora/pull/7694)
* Improve password autocomplete with password managers [#7642](https://github.com/diaspora/diaspora/pull/7642)
* Removed the limit of participants in private conversations [#7705](https://github.com/diaspora/diaspora/pull/7705)
* Send blocks to the blocked persons pod for better UX [#7705](https://github.com/diaspora/diaspora/pull/7705)
## Bug fixes
* Fix invite link on the contacts page when the user has no contacts [#7690](https://github.com/diaspora/diaspora/pull/7690)
......
......@@ -9,7 +9,7 @@ module Workers
protected
def schedule_retry(retry_count, sender_id, obj_str, failed_urls)
if retry_count < MAX_RETRIES
if retry_count < (obj_str.start_with?("Contact") ? MAX_RETRIES + 10 : MAX_RETRIES)
yield(seconds_to_delay(retry_count), retry_count)
else
logger.warn "status=abandon sender=#{sender_id} obj=#{obj_str} failed_urls='[#{failed_urls.join(', ')}]'"
......
......@@ -8,13 +8,13 @@ describe Workers::SendBase do
end
it "increases the interval for each retry" do
expect(Workers::SendBase.new.send(:seconds_to_delay, 2)).to be >= 625
expect(Workers::SendBase.new.send(:seconds_to_delay, 3)).to be >= 1_296
expect(Workers::SendBase.new.send(:seconds_to_delay, 4)).to be >= 2_401
expect(Workers::SendBase.new.send(:seconds_to_delay, 5)).to be >= 4_096
expect(Workers::SendBase.new.send(:seconds_to_delay, 6)).to be >= 6_561
expect(Workers::SendBase.new.send(:seconds_to_delay, 7)).to be >= 10_000
expect(Workers::SendBase.new.send(:seconds_to_delay, 8)).to be >= 14_641
(2..19).each do |count|
expect(Workers::SendBase.new.send(:seconds_to_delay, count)).to be >= ((count + 3)**4)
end
# lets make some tests with explicit numbers to make sure the formula above works correctly
# and increases the delay with the expected result
expect(Workers::SendBase.new.send(:seconds_to_delay, 9)).to be >= 20_736
expect(Workers::SendBase.new.send(:seconds_to_delay, 19)).to be >= 234_256
end
end
......@@ -41,4 +41,21 @@ describe Workers::SendPrivate do
Workers::SendPrivate.new.perform(sender_id, obj_str, targets, 9)
}.to raise_error Workers::SendBase::MaxRetriesReached
end
it "retries contact entities 20 times" do
contact = Fabricate(:contact_entity, author: sender_id, recipient: alice.diaspora_handle)
obj_str = contact.to_s
targets = {"https://example.org/receive/user/guid" => "<xml>post</xml>"}
expect(DiasporaFederation::Federation::Sender).to receive(:private).with(
sender_id, obj_str, targets
).and_return(targets).twice
expect(Workers::SendPrivate).to receive(:perform_in).with(a_kind_of(Numeric), sender_id, obj_str, targets, 19)
Workers::SendPrivate.new.perform(sender_id, obj_str, targets, 18)
expect(Workers::SendPrivate).not_to receive(:perform_in)
expect {
Workers::SendPrivate.new.perform(sender_id, obj_str, targets, 19)
}.to raise_error Workers::SendBase::MaxRetriesReached
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