Repository navigation
Skip reactions to Telegram updates that arrive more than 5 minutes late - #306
Merged
Merged
Conversation
After the 2026-11-20 Bot API outage Telegram redelivered about 58,000 messages that were up to 4.5 hours old. The Postgres inbox consumer handled every one of them, so the bot answered hour-old chat, drew old requests and queued old voice messages, while live traffic waited. The consumer now compares the Telegram time of the user action with the claim time. A message or edit older than 5 minutes is written to history and closed as ignored (`stale_update`) without reaching the router. Payments, refunds and membership or chat-id service messages still run their handlers however late they are. Callback, inline and pre-checkout queries carry no action time and are handled as before.
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.
Problem
On 2026-11-20 the Bot API stopped serving this bot from 13:42 to about 15:04 UTC. When it recovered, Telegram redelivered the backlog: from 15:00 to 15:36 UTC the inbox received 88,146 messages and edits, and 57,866 of them were more than 5 minutes old (the oldest by 4.5 hours). The Postgres inbox consumer deliberately ignored Telegram event time, so the bot answered hour-old chat, drew old requests and queued old voice messages while live messages waited.
Change
openplotva-updates:update_event_unix_datereads the Telegram time of the user action (dateof a message,edit_dateof an edit).update_is_late_atsays whether that time is older than a limit.stale_update_requires_handlenow also keeps refunds and the service messages that change who is in a chat or its id (new or left members, group to supergroup migration, group created). Successful payments were already on the list.openplotva-appinbox consumer: a message or edit older than 5 minutes at claim time goes throughUpdateHandler::record_late_update.UpdateHandlerWithHistorywrites it to history and does not call the router. The inbox row closes asignoredwith reasonstale_update, so the skip can be counted in SQL and the runtime API.Verification
cargo fmt --allcargo clippy --workspace --all-targets -- -D warningson the pinned 1.99.0 toolchaincargo test -p openplotva-updates -p openplotva-app: 93 and 1473 passededit_date, button under an old message), the exemptions (payment, refund, new members), history without routing, and the inbox outcome mapping