Repository navigation
fix(jira): send startAt and maxResults when collecting worklogs - #9324
Merged
Merged
Conversation
Signed-off-by: Ryo Kusnadi <ryokusnadi@gmail.com>
1 of 2 tasks
klesh
approved these changes
Nov 4, 2026
klesh
left a comment
Contributor
There was a problem hiding this comment.
LGTM
Thanks for your contribution.
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.
pr-type/bug-fix,pr-type/feature-development, etc.Summary
Problem: For a Jira issue with more than 20 worklogs,
collectWorklogssends the same request once per page. Every response holds the same worklogs, so_raw_jira_api_worklogsgets aboutn * ceil(n/50)rows instead ofn. The raw table grows fast andextractWorklogshas to read all of it. The reporter saw a 44 GB raw table and a 13 h extractor.How it happens: The collector only picks issues with
worklog_total > 20. For these it readstotalfrom the first response, soGetTotalPagesFromResponsereturnsceil(total/50).fetchPagesDeterminedthen sends one request per page. The URL template does not use the pager andQueryreturnednil, so every page request isapi/2/issue/{id}/worklogwith no parameters. Any issue with 21 or more worklogs triggers this.Cause:
Queryinbackend/plugins/jira/tasks/worklog_collector.goreturnednil, nil(added in #7466 with the comment that the API returns all worklogs). The paging loop was kept, but nothing told Jira which page to return.Fix:
Querynow setsstartAtandmaxResultsfromreqData.Pager, the same wayissue_changelog_collector.godoes. I moved it into a named function,buildWorklogQuery, so a unit test can call it.Scope:
startAt; I did not find another one with an emptyQuery.startAton this endpoint. If it ignores it, the requests stay identical, as they are today, so nothing gets worse.extractWorklogsto a stateful extractor. It is a separate change.Testing:
TestBuildWorklogQuerychecksstartAtandmaxResultsfor pages 1, 2 and 10.Queryreturningnil(the old behaviour) it fails:startAt = "", want "0". With the fix it passes.go vet ./plugins/jira/tasks/,go test ./plugins/jira/tasks/ -run TestBuildWorklogQueryandgofmt -lon the two changed files.Risk: Low. Only the query string of the worklog request changes, and only for issues with more than 20 worklogs. To roll back, revert the commit.
Does this close any open issues?
Closes #9323
Screenshots
N/A
Other Information
None.