Bound query scan to prevent full-DB page-fault thrash - #160
Conversation
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe store now applies a configurable scan multiplier to bounded queries, supports uncapped ChangesQuery scan limits
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ExportOrSpider
participant Store
participant QueryIterator
ExportOrSpider->>Store: queryFull(filters, limit)
Store->>QueryIterator: init(filters, limit, 0)
QueryIterator->>QueryIterator: scan index entries without a cap
QueryIterator-->>ExportOrSpider: matching events
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/store.zig (1)
398-401: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winApply the configurable multiplier to
queryMultiKindscans.
queryMultiKindcontinues to use a hardcodedlimit * 20cap, completely ignoringself.query_scan_multiplier. This breaks the configuration contract—if an administrator configures the multiplier to0(uncapped) or50, multi-kind queries will still stubbornly enforce a20xbound.Additionally, using saturating arithmetic (
*|) prevents potential integer overflows iflimitis exceptionally large.🐛 Proposed fix to enforce the configured bound
- var scanned: u32 = 0; - const max_scan: u32 = limit * 20; - - while (entry != null and collected < limit and scanned < max_scan) : (entry = try cursor.get(.prev)) { + var scanned: u32 = 0; + const max_scan: u32 = if (self.query_scan_multiplier == 0) 0 else limit *| self.query_scan_multiplier; + + while (entry != null and collected < limit and (max_scan == 0 or scanned < max_scan)) : (entry = try cursor.get(.prev)) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/store.zig` around lines 398 - 401, Update the queryMultiKind scan limit calculation around scanned and max_scan to use self.query_scan_multiplier instead of the hardcoded 20 multiplier. Preserve the configured uncapped behavior when the multiplier is 0, and use saturating multiplication (*|) so exceptionally large limits cannot overflow; keep the existing scan loop behavior otherwise.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/store.zig`:
- Around line 398-401: Update the queryMultiKind scan limit calculation around
scanned and max_scan to use self.query_scan_multiplier instead of the hardcoded
20 multiplier. Preserve the configured uncapped behavior when the multiplier is
0, and use saturating multiplication (*|) so exceptionally large limits cannot
overflow; keep the existing scan loop behavior otherwise.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 436e241c-656f-4b98-ac85-9ba095245913
📒 Files selected for processing (4)
src/config.zigsrc/main.zigsrc/spider.zigsrc/store.zig
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/handler.zig`:
- Around line 714-717: Update the serving-side enumeration around
self.store.query so reconciliation never seals a capped or incomplete event set:
use the uncapped queryFull path, or detect a scan-cap condition and return
NEG-ERR instead. Preserve the existing network-safe behavior only if truncation
is explicitly surfaced and handled as an error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2353f2b0-2bb9-4f00-aa37-c5abe5ae3fa9
📒 Files selected for processing (5)
docs/configuration.mdsrc/handler.zigsrc/main.zigsrc/store.zigwisp.toml.example
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main.zig
- src/store.zig
Summary by CodeRabbit
query_scan_multiplier([limits], default20) to cap per-query index scanning aslimit × multiplier(set to0to disable).WISP_QUERY_SCAN_MULTIPLIERsupport for controlling the multiplier via environment variables.wisp.toml.examplewith the new setting and behavior.