chanevents: add channel event pruning#245
Conversation
Add a PruneChannelEvents query that bounds the channel_events table by both size and age in a single statement: an id-keyset offset enforces a maximum event count and a timestamp filter enforces a retention window, OR-joined so each limit applies independently. The query returns the number of rows deleted so callers can surface pruning activity. Add a standalone timestamp index so the global age-based prune does not scan the full table. The existing composite index leads with channel_id and cannot serve a channel-agnostic timestamp filter.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a safety mechanism to prune the Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a channel event pruning mechanism to Faraday to bound database growth by size and age. It adds configuration options, a background monitor loop, a database migration for a timestamp index, and tests. The reviewer's feedback identifies several improvement opportunities: enforcing a minimum interval for the background pruning ticker to prevent CPU starvation, validating that retention is not negative, removing an unnecessary transaction wrapper for a single query to reduce overhead, and softening a strict assertion in the integration test to avoid CI/CD flakes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
ViktorT-11
left a comment
There was a problem hiding this comment.
Looks good! Just leaving a few suggestions which are non-blocking
|
|
||
| for { | ||
| select { | ||
| case event, ok := <-eventChan: |
There was a problem hiding this comment.
We could maybe also activate pruning once a number of events of a threshold limit has been handled, which resets the ticker. Just to avoid that we'd get a lot of events in one hour which makes the db much larger than the intended max size.
There was a problem hiding this comment.
I didn't address this, I think we can get to that later if we really need such high-fidelity
98db189 to
9580616
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a channel event pruning mechanism to prevent unbounded database growth by adding size-based (max-events) and age-based (retention) limits. The review feedback highlights a critical integer overflow risk during type casting that could lead to unintended data loss, a potential nil pointer dereference when initializing the monitor, and an optimization opportunity to avoid running a background ticker when pruning is disabled.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
We add regular channel event pruning, as otherwise the database may get filled quickly. We add two mechanisms, a retention time and a max events number. Both can be turned on individually.
Add an integration test to verify the safety pruning behavior under various conditions.
Document the new configuration flags in the README, providing rough storage estimation metrics (~100 bytes per event) to guide database sizing.
9580616 to
754d660
Compare
Bounds the
channel_eventstable, which otherwise grows without bound on high-frequency channels. Pruning is on by default with two independent limits:--chanevents.max-events=7000000(~1GB of storage)--chanevents.retention=1440h (60 days)Both parameters can be used independently and the pruning interval is about an hour.