[Bug][dora] calculateChangeLeadTime loads the whole commits_diffs deployment join into memory
維護者通常 2 天內回覆
已經有一個關聯 PR 被合併了。
- #9281 來自 @mdelacruz-avantio —— 已合併
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- go
研究方向
Start with batchFetchDeployments in backend/plugins/dora/tasks/change_lead_time_calculator.go and inspect how the second phase joins cicd_deployment_commits with commits_diffs. The issue proposes streaming rows into a three-column struct while preserving the joins, filters, ordering, and first-wins tie-break; an open pull request already tracks this work. Done means memory scales with distinct merge commits and the tie-break has an end-to-end test.
由索引模型根據 Issue 內容生成。
描述
Search before asking
- I had searched in the issues and found no similar issues.
What happened
batchFetchDeployments in backend/plugins/dora/tasks/change_lead_time_calculator.go resolves merge commits to deployments in two phases. The second phase joins cicd_deployment_commits with commits_diffs, loads every joined row into a slice of full CicdDeploymentCommit structs with db.All, and only then keeps the first row per merge commit in Go.
Memory therefore grows with the size of the join, not with the number of merge commits. The join has one row per commit between a production deployment and its previous successful one, for every merge commit in that range. On a project where deployments are far apart in commit history, or where a deployment job records a commit from a second repository with a long history, the join becomes very large.
On our instance the query returns about 936,000 rows for 14,088 distinct merge commits (1,693 production deployment commits). The lake container peaks at about 1.7 GiB in this subtask, is OOMKilled at a 2 GiB limit on every nightly run, and then crash loops because each restart resumes the same pipeline at the same subtask. The row count grows every week.
What do you expect to happen
The memory used by this subtask stays proportional to the number of distinct merge commits, as the first phase already does, whatever the size of the commits_diffs join.
How to reproduce
- A project with a few hundred production deployment commits where consecutive deployments are thousands of commits apart, so
commits_diffsholds many rows per deployment pair. - Run the DORA pipeline and watch the lake container memory during
calculateChangeLeadTime, or count the rows the second phase loads:
SELECT COUNT(*), COUNT(DISTINCT cd.commit_sha)
FROM cicd_deployment_commits dc
LEFT JOIN cicd_deployment_commits p ON dc.prev_success_deployment_commit_id = p.id
INNER JOIN commits_diffs cd ON cd.new_commit_sha = dc.commit_sha AND cd.old_commit_sha = COALESCE(p.commit_sha, '')
LEFT JOIN project_mapping pm ON pm.table = 'cicd_scopes' AND pm.row_id = dc.cicd_scope_id
WHERE dc.prev_success_deployment_commit_id <> '' AND dc.environment = 'PRODUCTION' AND dc.result = 'SUCCESS' AND pm.project_name = '<project>';
The first number is what the subtask materialises, the second is what it keeps.
Anything else
Streaming the second phase with db.Cursor and db.Fetch into a three-column struct and keeping the first row per merge commit, with the same joins, filters and ordering, makes the memory independent of the join size. I will open a pull request with that change and an e2e case for the first-wins tie-break.
Raising the container memory limit and setting GOMEMLIMIT is a stopgap only, the peak keeps growing with the join.
Version
v1.0.3-beta18. The function is unchanged on main at 625e512a4.
- 主要語言
- Go
- 星號
- 3.2k
- 分支
- 832
- 平均合併
- 2 天 6 小時
- 30 天內合併 PR
- 62
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/devlake 的其他 Issue
-
type/bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 60/100
維護者通常 2 天內回覆
-
[Bug][claude_code] Incremental collection stops after the first run可能已有人在做 @clementsen 今天認領。 未關閉
難度 3/5 1-2 天 新手友好度 32/100
維護者通常 2 天內回覆
-
type/bug
難度 3/5 半天 新手友好度 73/100
維護者通常 2 天內回覆
-
[Refactor][Build] Build the core and all plugins into a single binary by default可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉component/plugins type/refactor
難度 5/5 一週以上 新手友好度 25/100
維護者通常 2 天內回覆
相似的 Issue
-
docs(prompts): IF BLOCKED workflow-scope branch says to comment on the issue on jira/local trackers未關閉agent-butler-finding bug
難度 2/5 1-3 小時 新手友好度 77/100
jordansmall/spindrift#6238 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
microcks/microcks-cli#608 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug from-studio
難度 2/5 1-3 小時 新手友好度 65/100
esengine/DeepSeek-Reasonix#14868 ·
維護者通常 1 天內回覆
-
Install notes print "Camunda REST API: https://" without a host when global.host is set可能已有人在做 @irisfield 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
camunda/camunda-platform-helm#7790 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
wso2/agent-manager#2220 ·
維護者通常 1 天內回覆