Repository navigation
fix(dora): stream the diff-based deployment fetch in calculateChangeLeadTime - #1
Merged
mdelacruz-avantio merged 1 commit intoOct 29, 2026
Conversation
Collaborator
|
/review |
There was a problem hiding this comment.
Summary
The PR changes the phase-2 query in batchFetchDeployments so it reads the cicd_deployment_commits × commits_diffs join one row at a time with db.Cursor/db.Fetch into a three-column struct, instead of loading every full CicdDeploymentCommit row into a slice. It also trims phase 1 to id, finished_date, commit_sha. A new e2e case checks that the earliest-started deployment wins over the lower id. The result logic is unchanged and the fix is correct.
Verdict: approve
Findings
Minor
backend/plugins/dora/tasks/change_lead_time_calculator.go:337-340: map values are now partialCicdDeploymentCommitstructs: phase 2 fills onlyId/FinishedDate, and phase 1 also hasCommitSha. Today this is safe, because the only consumer (lines 136-142) reads justdeployment.FinishedDateanddeployment.Id, and the function comment at lines 282-283 documents this. Returning a small dedicated type such asmap[string]*diffDeploymentwould let the compiler enforce that contract instead of relying on a comment. This is optional.backend/plugins/dora/e2e/change_lead_time/*(pr8 tie case): this test would also pass against the olddb.Allcode, since ordering and first-wins are unchanged. So it guards thestarted_date-before-idordering against regressions, not the streaming change itself. That's fine as a parity check, just worth knowing.
Assessment
I checked the change closely:
- Ordering and first-wins: the cursor loop keeps the same
ORDER BY cd.commit_sha, dc.started_date ASC, dc.id ASC, the same first-wins rule, and phase 1 still takes precedence. - Cursor handling:
defer cursor.Close()and thecursor.Err()check are both in place. - Scanning:
Dalgorm.FetchusesScanRows, which mapsid/finished_date/merge_shaontodiffDeploymentcorrectly. - New fixture: the pr8 values work out: deploy time 66 min (merged 07:00, deployed 08:06) and cycle time 1440+60+66=1566. Deployment 19 is reachable through cicd2→project1 with prev deployment 13 on commit13.
It's ready to merge.
✅ Approved by Onyx Agent — verdict approve, no Critical or Important findings.
Review by Onyx Agent — react with 👍 / 👎 to help it improve.
pballester
approved these changes
Oct 29, 2026
mdelacruz-avantio
merged commit Oct 29, 2026
69cc749
into
avantio/v1.0.3-beta18-patched
5 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Same change as apache#9281, carried on our release line until an upstream release contains it.
batchFetchDeploymentsloaded the wholecicd_deployment_commitsxcommits_diffsjoin into a slice of fullCicdDeploymentCommitrows before keeping the first row per merge commit. On our instance that join returns about 936k rows for 14k merge commits, the lake container peaked at about 1.7 GiB in this subtask and was OOMKilled on every nightly run.db.Cursoranddb.Fetchone row at a time into a struct withid,finished_dateandmerge_sha, keeping the first row per merge commit. Joins, filters and ordering are unchangeddc.id, dc.finished_date, dc.commit_shainstead ofdc.*cursor.Err()is checked after the loopIdandFinishedDateChecks
Rollout
Image
v1.0.3-beta18-avantio.2is built from the merged tip of this branch and pinned in k8s-infraapps/devlake/values/values.yamlby tag and digest.