feat(updates): add getDifference reason and unknown-peer diagnostics#1781
Merged
Conversation
Make update-stream resyncs traceable for issues like #1623 where a user account stops receiving updates until it acts. - Thread a reason string through getDifference/getDifferenceLogger for both the common and channel state; the "Getting difference" log now carries the reason plus current pts/qts/seq/date (channel_id/pts for channels), so every resync is attributable to its trigger. - Log the offending user_id in userPeersKnown when an access hash is unknown, the exact signal behind a forced getDifference for an unresolved peer. Diagnostics only, at Debug level; no behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1781 +/- ##
==========================================
+ Coverage 71.32% 71.39% +0.06%
==========================================
Files 504 504
Lines 23625 23640 +15
==========================================
+ Hits 16851 16878 +27
+ Misses 5542 5533 -9
+ Partials 1232 1229 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Motivation
Reports like #1623 ("some
UpdateNewMessageupdates are not received until I send a message myself") are hard to diagnose from logs. Theupdatespackage already logs gap detection in detail, but two crucial things were invisible:getDifferencefired — it is called from ~20 sites (startup, pts/qts/seq gap timeouts, idle timeout, the access-hash peer gates from feat(updates): force getDifference for updates referencing peers with unknown access hash #1738,updatesTooLong, seq-pts-changed, slice/too-long continuations, channel subscribe/too-long/idle) and every one logged the same bare"Getting difference".userPeersKnown) silently forced agetDifferencewith no record of the offending user, which is the exact signature of the "stranger messages me first" case.Changes
reason stringthroughgetDifference/getDifferenceLoggerfor both the common (internalState) and channel (channelState) paths. The"Getting difference"log now includes the reason plus currentpts/qts/seq/date(channel_id/ptsfor channels).user_id(and whether it was a hasher error vs. a cache miss) inuserPeersKnownwhen an access hash is unknown.A #1623-style trace now reads:
reasonvalues are stable kebab-case tokens (pts-gap-timeout,combined-peer-access-hash-unknown,channel-too-long, …) so they are greppable and could later back a metric label.Notes
Testing
go test ./telegram/updates/passesgo build ./...,go vet,gofmtclean🤖 Generated with Claude Code