Skip to content

connector: pace media re-requests instead of firing them in a burst - #945

Open
aminebalti55 wants to merge 1 commit into
mautrix:mainfrom
aminebalti55:pr/pace-media-requests
Open

connector: pace media re-requests instead of firing them in a burst#945
aminebalti55 wants to merge 1 commit into
mautrix:mainfrom
aminebalti55:pr/pace-media-requests

Conversation

@aminebalti55

Copy link
Copy Markdown

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 in sendMediaRequests did 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 getChatInfo on ErrIQRateOverLimit a few lines away in backfill.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.

gofmt and go vet clean.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant