Skip to content

fix(lapis): do not cache aggregations with many group by fields - #1850

Merged
fhennig merged 1 commit into
mainfrom
dont-cache-large-groupby-aggregations
Sep 3, 2026
Merged

fix(lapis): do not cache aggregations with many group by fields#1850
fhennig merged 1 commit into
mainfrom
dont-cache-large-groupby-aggregations

Conversation

@fhennig

@fhennig fhennig commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

resolves #1849

Aggregations that group by more than 20 columns (plain fields plus sequence-position fields) are no longer cached. The cache materializes the full result into a List to store it; for high-cardinality group-bys this can exhaust the heap (and did, causing a LAPIS outage). Such queries are now streamed straight through instead. Their cache hit rate is close to zero anyway since each filter combination is unique.

PR Checklist

  • All necessary documentation has been adapted.
  • All necessary changes are explained in the llms.txt.
  • The implemented feature is covered by an appropriate test.

Aggregations that group by more than 20 columns (plain fields plus
sequence-position fields) are no longer cached. The cache materializes the
full result into a List to store it; for high-cardinality group-bys this
can exhaust the heap (and did, causing a LAPIS outage). Such queries are
now streamed straight through instead. Their cache hit rate is close to
zero anyway since each filter combination is unique.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5mqrj8VN12QZfxqGNEb1d
@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
lapis Ready Ready Preview Sep 3, 2026 9:23am UTC

Request Review

@fhennig
fhennig requested a balanced review from Copilot September 3, 2026 09:24
@fhennig fhennig self-assigned this Sep 3, 2026

Copilot AI 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.

🟢 Approval recommended

The implementation matches the stated requirement and includes appropriate unit and client-level coverage.

Pull request overview

Prevents heap exhaustion by streaming aggregations grouped by more than 20 fields instead of caching them.

Changes:

  • Adds a maximum cacheable group-by field count.
  • Counts metadata and sequence-position fields together.
  • Tests cacheability and uncached client behavior.
File summaries
File Description
lapis/src/main/kotlin/org/genspectrum/lapis/silo/SiloQuery.kt Disables caching above the threshold.
lapis/src/test/kotlin/org/genspectrum/lapis/silo/SiloQueryTest.kt Tests threshold behavior.
lapis/src/test/kotlin/org/genspectrum/lapis/silo/SiloClientTest.kt Verifies large aggregations bypass caching.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@fengelniederhammer fengelniederhammer 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.

Looks reasonable 👍

@fhennig
fhennig merged commit 2a46e72 into main Sep 3, 2026
10 checks passed
@fhennig
fhennig deleted the dont-cache-large-groupby-aggregations branch September 3, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable caching for large/overly-specific queries

3 participants