Repository navigation
fix: keep the comment reader reading after a bogus head comment ID - #103
Merged
Merged
Conversation
On 2026-10-17 the r/all listing returned a comment ID of about 6 * 10^18. The reader skipped ahead to it, never saw a higher head again and scanned nothing for hours. Outlier IDs in the listing and implausible head jumps are now ignored, a position far ahead of every head resets itself, and the heartbeat warns when heads were found but nothing was read. Adds unit and live regression tests. Co-Authored-By: Toldry <toldry@gmail.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ddUNNyEKK7YQuAyfKfGwi
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.
Before: since about 00:20 UTC on 2026-10-17 the bot scanned 0 comments. The heartbeat showed
reads: 0 requests, a lag of about -6 × 10^18 IDs, and about 10^12 "IDs skipped" every 10 minutes. The r/all listing had returned one comment ID of about 6 × 10^18 (real IDs are about 8 × 10^10). The reader skipped ahead to it, never saw a higher head again, and stopped reading.After: such an ID is ignored. If a bogus position ever gets in anyway, the reader resets itself within a minute. The heartbeat now warns when heads were found but nothing was read. Deploying this also recovers the stuck production reader, because a saved cursor ahead of the newest comment is ignored at startup.
How:
fetch_headdrops listing IDs more thanMAX_BACKLOG_IDSfrom the median (newest_consistent_id).poll_headrejects a head further past the last accepted head (or the saved cursor) thanMAX_BACKLOG_IDS + 2,000 IDs/s × elapsed. It logs this once per streak and counts it asrejectedin the heartbeat.Tests:
CommentReaderruns for 45 s and must read at least 200 comments with a sane lag. This is the check that would have caught this outage before the deploy.Locally:
uv run pytestgives 1804 passed. The live tests run only on master in CI.Generated by Claude Code