Skip to content

feat: only use cache for row lookups if cache is available - #3816

Open
knudtty wants to merge 1 commit into
mainfrom
aaron/cache-friendly-row-lookup
Open

knudtty wants to merge 1 commit into
mainfrom
aaron/cache-friendly-row-lookup

Conversation

@knudtty

@knudtty knudtty commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Sometimes if a row doesn't exist in the cache, CH will pull a bunch of extra data and fill up the cache a bit. It's unnecessary for the row lookup queries. The setting read_from_filesystem_cache_if_exists_otherwise_bypass_cache is self explanatory and can help latency significantly.

Screenshots or video

image

References

  • Linear Issue: Closes HDX-6187

@knudtty
knudtty requested a review from a team as a code owner November 24, 2026 20:05
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 24, 2026 8:06pm UTC
hyperdx-storybook Ready Ready Preview Nov 24, 2026 8:06pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 115063b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

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

@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 1
  • Production lines changed: 17 (+ 29 in test files, excluded from tier calculation)
  • Branch: aaron/cache-friendly-row-lookup
  • Author: knudtty

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 107 in total (1.12%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

2 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 1 P3

None could be anchored to changed lines; they are listed below. 1 P3 folded at the bottom.

Findings outside the changed lines

  • 🟡 P2 packages/cli/src/api/eventQuery.ts:379 — CLI port of useRowData does not get the new filesystem-cache setting → buildFullRowQuery has an @source packages/app/src/components/DBRowDataPanel.tsx (useRowData) tag and claims to match the web row lookup. It still renders with source.querySettings alone, and so does buildTraceRowDetailQuery, which is also a single-row SELECT *. So the web and CLI lookups now behave differently. Move ROW_LOOKUP_QUERY_SETTINGS into common-utils and pass it, merged with the source settings (source values win), in both CLI builders. Otherwise, say in the cli Web Frontend Alignment notes that the port intentionally leaves the setting out.
🔵 1 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/components/DBRowDataPanel.tsx:58 — New constant splits the rowLookupStaleTime doc comment away from the function it describes → Lines 54-57 describe rowLookupStaleTime: a found row is reused and a miss stays stale. The new comment and ROW_LOOKUP_QUERY_SETTINGS were inserted between that comment and the function, so the stale-time explanation now reads as the doc for the settings constant. Move the constant and its two-line comment above line 54, or below rowLookupStaleTime.

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.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a small, focused change: row side-panel lookups now always append read_from_filesystem_cache_if_exists_otherwise_bypass_cache=1. The code is well-typed (the ?? [] guard is correct), the setting is correctly deduplicated against source-level settings by mergeQuerySettings (source wins), the per-render array does not destabilize the react-query key (keys are hashed by value), and the behavior is well covered across the viewer-off / viewer-on / source-sets-asterisk / known-columns branches. The changeset is present and correctly scoped as an @hyperdx/app patch.

🟡 P2 -- recommended

  • packages/app/src/components/DBRowDataPanel.tsx:288 -- Every row lookup now emits a SETTINGS clause where the default path previously emitted none, so a ClickHouse connection whose user profile is readonly=1 rejects all row-panel lookups with error 164 (READONLY) instead of succeeding as before; builder-config lookups get clickHouseSettings={} (no readonly:2) and there is no strip-and-retry, so the error surfaces to the panel.
    • Fix: Send the cache setting best-effort -- either gate it on a connection known to tolerate custom settings (mirroring how the materialized/alias settings are only added when the viewer option is on), or add a fallback that re-runs the lookup without the setting when the connection rejects it.
    • reliability, correctness, testing
  • packages/app/src/components/__tests__/DBRowDataPanel.test.ts:434 -- The readonly-rejection test asserts only expect(options?.additionalQuerySettings).toBeDefined(), which is now trivially true since the array is always non-empty, so a regression that dropped the cache setting under readonly would pass undetected.
    • Fix: Assert expect(options?.additionalQuerySettings).toContainEqual(ROW_LOOKUP_SETTING) so the test pins that the always-on setting is actually sent on the readonly path.
🔵 P3 nitpicks (1)
  • packages/app/src/components/DBRowDataPanel.tsx:54 -- Inserting ROW_LOOKUP_QUERY_SETTINGS between the pre-existing tab-reuse/staleness comment and the rowLookupStaleTime function it documents, and appending the filesystem-cache lines to that same block, makes it ambiguous which comment documents which symbol.
    • Fix: Split the comment so the staleness lines sit directly above rowLookupStaleTime and only the two cache lines sit above the new constant.

Reviewers (6): correctness, reliability, performance, testing, maintainability, project-standards.

Testing gaps:

  • No test exercises graceful degradation when a connection rejects the new cache setting (readonly=1 or an older ClickHouse that does not recognize the setting); current coverage confirms errors surface but not that the panel recovers.
  • No test asserts a source that sets read_from_filesystem_cache_if_exists_otherwise_bypass_cache itself still wins over the new default via mergeQuerySettings.

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

@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 478 passed • 1 skipped • 1203s

Status Count
✅ Passed 478
❌ Failed 0
⚠️ Flaky 10
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@wrn14897 wrn14897 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any concerns about the failed CI runs?

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 115063bc Deployed Nov 24, 2026 by vercel[bot]
Preview – hyperdx-storybook — 115063bc Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants