connector: pace media re-requests instead of firing them in a burst - #945
Open
aminebalti55 wants to merge 1 commit into
Open
connector: pace media re-requests instead of firing them in a burst#945aminebalti55 wants to merge 1 commit into
aminebalti55 wants to merge 1 commit into
Conversation
On first link of a number with real history, backfill surfaces old media whose contents have expired on the server, and every one of those became a re-request stanza fired in a tight loop - dozens to hundreds within milliseconds, immediately after the device linked, on by default. The daily sweep in sendMediaRequests did the same. A phone fetches expired media one item at a time as a person scrolls into a chat; it does not do this. The bridge already backs off getChatInfo on ErrIQRateOverLimit a few lines away, so this was an inconsistency rather than a choice. Space the requests half a second apart with jitter, in both loops. Requests are saved to the database before being sent regardless, so one that does not go out in this pass is picked up by the next sweep rather than lost.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On first link of a number with real history, backfill surfaces old media whose contents have expired on the server, and every one of those became a re-request stanza fired in a tight loop — dozens to hundreds within milliseconds, immediately after the device linked, and on by default (
auto_request_media: true,request_method: immediate). The once-daily sweep insendMediaRequestsdid the same.A phone fetches expired media one item at a time as a person scrolls into a chat; it doesn't do this. The bridge already backs off
getChatInfoonErrIQRateOverLimita few lines away inbackfill.go, so this reads as an inconsistency rather than a choice.Space the requests 500 ms apart with up to 50% jitter, in both loops. Requests are saved to the database before being sent regardless, so one that does not go out in this pass is picked up by the next sweep rather than lost.
gofmtandgo vetclean.