Repository navigation
fix: skip exhausted search windows - #3587
adityareddy-dev wants to merge 10 commits into
Conversation
|
Hi @adityareddy-dev, thanks for the pull request! Before we review code from a first-time contributor, a maintainer vouches for them, and you're not on our list yet. There's nothing else to file and this PR stays open — a maintainer will look at it, usually within a day or two, and vouch for you right here if it's a genuine attempt at the problem. To make that quick, check the PR description has:
More detail in our contributing guide. |
PR Review
3 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 3 P3 No inline comments. 3 P3 folded at the bottom. 🔵 3 P3 — no action needed before merge
Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
bcacd17 to
b25c8cc
Compare
Deep Review✅ No critical issues found. The core fix is sound: every uncertain path ( 🟡 P2 — recommended
🔵 P3 nitpicks (2)
Pre-existing (not introduced by this diff):
Reviewers (11): correctness, adversarial, kieran-typescript, performance, reliability, testing, maintainability, project-standards, previous-comments, agent-native, learnings-researcher. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
ab7139d to
9263c98
Compare
|
Done. |
e508541 to
bdac94d
Compare
|
@adityareddy-dev is attempting to deploy a commit to the ClickHouse Team on Vercel. A member of the Team first needs to authorize it. |
2a44a78 to
7b0c09f
Compare
7b0c09f to
aa6623c
Compare
|
Fixed. |
ea17b69 to
01081a8
Compare
| }); | ||
| const sourceSettings = new Map( | ||
| source?.querySettings | ||
| ?.filter(({ setting, value }) => setting.length && value.length) |
There was a problem hiding this comment.
🔵 minor — Empty-setting filter copies joinQuerySettings and can drift from the SQL actually sent
The setting.length && value.length filter repeats the one in joinQuerySettings (packages/common-utils/src/core/utils.ts:1393), which decides which source settings reach the SQL SETTINGS clause. The inference here is only correct if both filters stay identical. Fix: export a small filterQuerySettings (or querySettingsToMap) helper from common-utils and use it in both places.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| source?.querySettings, | ||
| ); | ||
|
|
||
| let canSkipShortPage = false; |
There was a problem hiding this comment.
🔵 minor — The check for whether query limits can truncate a page is about 60 lines of logic written inline in the queryFn, and it repeats the empty-setting filter from joinQuerySettings
Move this logic into a pure helper next to joinQuerySettings in packages/common-utils/src/core/utils.ts (for example canResultBeTruncated(serverSettings, querySettings, queryTimeout, limit)). The helper should reuse that file's setting.length && value.length filter (utils.ts:1393) so the SETTINGS rendering and this check can't drift apart. Then unit-test it directly instead of through roughly 80 hook renders.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
🦋 Changeset detectedLatest commit: fae7739 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| ?.filter(({ setting, value }) => setting.length && value.length) | ||
| .map(({ setting, value }) => [setting, value]), | ||
| ); | ||
| // SQL SETTINGS override the timeout injected by the client, then server defaults. |
There was a problem hiding this comment.
🔵 minor — The hook keeps its own copy of how ClickHouse settings take effect, in two places
Move the settings check (lines 275-336) into a pure helper in packages/common-utils/src/core/utils.ts, next to joinQuerySettings. It would take the server settings, source settings, queryTimeout and the requested limit, and return a boolean. Today the inline code copies two pieces of logic. (1) The empty-pair filter at lines 281-283 repeats joinQuerySettings (core/utils.ts:1421). If the copies drift, the decision will be based on settings that differ from the SETTINGS clause actually sent. (2) The max_execution_time precedence (source setting, then the client timeout, then the server value) restates processClickhouseSettings (packages/common-utils/src/clickhouse/index.ts:609-614). A setting added to the client defaults later will not be counted here. Unit-test the helper directly instead of rendering the whole hook for each of the ~90 settings combinations.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
|
@karl-power can you vouch for me on this one? |
…arch-pages # Conflicts: # packages/app/src/hooks/__tests__/useOffsetPaginatedQuery.test.tsx
Summary
A short search page triggered another query in the same time window. I now skip that query only when the effective query limits rule out truncation. Capped or unknown results keep paging within the window.
Fixes #1403.
How to reproduce
Starting point: A search spanning multiple time windows, with a page limit of 100 and only one matching row in the first window.
On
main:OFFSET 1.On this branch:
throwor its limits disabled.OFFSET 0.How to test on Vercel preview
N/A, query pagination change with no visual changes.
References
#1403
Note
Medium Risk
Pagination behavior changes for search/time-windowed queries; incorrect truncation detection could skip real rows or issue extra queries, though logic is conservative when settings are unknown.
Overview
useOffsetPaginatedQueryno longer issues another offset query in the same time window when a page returns fewer rows than the page size and effective ClickHouse settings show results cannot be silently truncated (overflow modesthrowor caps disabled, merged from server metadata, sourcequerySettings, and team timeout).In those cases pagination advances to the next time window at offset 0 instead of probing
OFFSET nin an exhausted window. When caps orbreakoverflow modes might hide more rows—or settings are unknown—it still offsets within the window until an empty page or a full page proves continuation is safe.Each page now carries a computed
canSkipShortPageflag used bygetNextPageParam. Tests cover the overflow/limit matrix and related edge cases.Reviewed by Cursor Bugbot for commit fae7739. Bugbot is set up for automated code reviews on this repo. Configure here.