Bug: Time-series chart breakdowns can exhaust API memory before the series limit is applied
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- clickhouse, typescript
- Lĩnh vực
- backend, databases, performance
Hướng nghiên cứu
Start with the SQL builder in packages/core/src/modules/chart/src/sql.ts, the query reader in packages/core/src/modules/chart/src/run-query.ts, and the grouping and series formatting paths in packages/core/src/shared/group-by-labels.ts and packages/core/src/modules/chart/src/engine/. Reproduce the reported padding behavior with the synthetic example, then trace where result and point budgets can be enforced before full materialization and padding. Done when oversized breakdowns return a controlled error or bounded result, with ranking and aggregate-total semantics preserved.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
A time-series chart grouped by an event property with many distinct values can return millions of rows from ClickHouse. The API reads the entire JSON result into memory, builds all chart series, and applies the optional series limit at the end. In a self-hosted deployment, repeated requests with the same chart parameters were followed by API container terminations for exceeding their memory limit.
Versions checked
- Public source inspected at v3.32.0. The deployed chart code followed the same result-processing path.
- The earlier isolated pipeline experiment used v3.30.0 and Node.js 24.22.1.
Confirmed observations from a self-hosted deployment
- The failing request used
chart.chartfor a line chart with monthly buckets, an approximately one-week range, and one breakdown on an event property with many distinct values. It queried all events in the range, with no series limit specified. - ClickHouse completed each matching query successfully. Its query log reported roughly 10 million result rows and about 1 GB of result data per execution.
- Each large query was matched to the API container that requested it. The ingress log recorded the upstream connection closing before the response completed, and the corresponding API container was terminated for exceeding its memory limit (
OOMKilled). This sequence occurred repeatedly with the same chart parameters.
Confirmed source behavior
- The time-series SQL groups by date and the breakdown values. The time-bucket check bounds the number of dates. The query has no corresponding cap on the number of distinct groups or on the total result size. SQL builder
- The API awaits
result.json()for the complete response and then copies each row while converting numeric values. Query reader - The chart engine groups rows and fills every group across all observed time buckets. A sparse input with G distinct groups and T distinct time buckets can therefore expand to G × T points. Grouping and padding · Series construction
- The optional series limit is applied after series construction and formatting. A small display limit leaves the preceding allocations unbounded by that limit. Final series limit
Minimal local reproduction of point expansion
From the repository root at v3.32.0, pass this synthetic example to node --input-type=module - with Node.js 24. It runs the grouping helper without a database.
import { groupByLabels } from './packages/core/src/shared/group-by-labels.ts';
const dates = Array.from({ length: 32 }, (_, i) =>
new Date(Date.UTC(2025, 0, 1 + i)).toISOString().slice(0, 10) + ' 00:00:00'
);
const rows = Array.from({ length: 60_000 }, (_, i) => ({
label_0: 'demo_event',
label_1: `demo_key_${i}`,
date: dates[i % dates.length],
count: 1,
total_count: 1,
}));
const groups = groupByLabels(rows);
console.log(rows.length, groups.length, groups.reduce((n, g) => n + g.data.length, 0));
The output is 60000 60000 1920000. Each group has one input row and receives 32 points after padding. In the earlier isolated pipeline experiment, setting the final limit to 50 still produced 1,920,000 intermediate points, then returned 50 series / 1,600 points. That experiment bypassed the database and completed without an out-of-memory crash.
Likely mechanism and remaining uncertainty
The incident evidence points to a memory spike while the API handled the unusually large query result. Full JSON parsing, row copies, and series construction are all plausible contributors. There was no heap profile for the failing requests, so the exact allocation that crossed the limit and the contribution of each stage remain unknown. The synthetic test demonstrates the separate effect of padding sparse groups across many buckets. The production request used monthly buckets, so the synthetic expansion ratio should not be used to estimate production memory use.
Difference from related issues
- #426 concerns ClickHouse materializing profiles for a whole project during a chart join. Its fix narrows that join to profiles active in the chart's event window. The query in this report grouped by an event property and had no profile join. Fix for #426
- #382 concerns memory used by session path arrays inside ClickHouse. Its fix changes how consecutive path steps are deduplicated. The query here was a time-series chart that completed in ClickHouse, then exhausted memory in the API. Resolution of #382
Expected behavior
A chart that exceeds a safe processing budget should return a controlled error or a bounded result without taking the API process down. A fix should bound the result before full JSON materialization and also bound the number of points created during padding. If it selects the top groups earlier, it should preserve the ranking and aggregate-total semantics.
- Ngôn ngữ chính
- TypeScript
- Star
- 7.3k
- Fork
- 552
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Openpanel-dev/openpanel
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Openpanel-dev/openpanel#696 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug: Saved reports lose their custom event selection after reloadCó thể đã có người làm @shiv-shi đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Openpanel-dev/openpanel#694 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Free trial banner overlaps the AI Chat sidebarCó thể đã có người làm @VasuS609 đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Openpanel-dev/openpanel#690 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Openpanel-dev/openpanel#653 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Openpanel-dev/openpanel#610 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Openpanel-dev/openpanel
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
ardia-browser/ardia#6391 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Feature:Actions/ConnectorTypes Team:ResponseOps
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
elastic/kibana#309028 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🔨 tool 🧰 library
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Orange-OpenSource/Orange-Boosted-Bootstrap#4035 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Ajouter la page Plan du siteĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
DISIC/teleservice-conformite#230 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
rothgar/rabble.radio#410 ·
Maintainer thường phản hồi trong vòng 1 ngày