Repository navigation
fix: bound FULL task pages by size in bytes - #458
Conversation
Pages of `GET /tasks?view=FULL` now also end before their tasks exceed `custom.controllers.list_tasks.max_page_bytes_full` bytes of JSON (default 10 MiB), besides `max_page_size_full` tasks. A page always has at least one task, and its `next_page_token` continues after the last task served. Document the setting, its memory bound, the chart's notes and the upgrade note. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Responses are indented JSON (connexion indents by 2 spaces), so a task takes up to several times its compact size in the body. Count each task with its size in the body, and fetch tasks of the view FULL one at a time, so that the driver decodes no task beyond the end of a page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bound counts the response body; decoded tasks with many small fields take up to about 7 times its size in memory. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideData structuresAdd the positive
ImplementationMeasure FULL tasks as they appear in the indented response and stop before exceeding the byte limit while preserving paging and fetching one task at a time.
ConfigurationSet the new byte limit in the application defaults and Helm chart, and explain the chart’s memory sizing alongside its existing task-count limit.
DocumentationDocument the new FULL-page byte limit, its paging behavior, memory implications, deployment guidance, and upgrade impact.
TestsVerify served-size accounting, one-at-a-time FULL fetching, byte- and count-limited paging, the minimum-one-task behavior, and configuration validation.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #458 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 31 31
Lines 2998 3013 +15
=========================================
+ Hits 2998 3013 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pro_tes/config_models.py" line_range="194" />
<code_context>
# full tasks may be large (e.g., with inline contents of inputs)
max_page_size_full: PositiveInt = 64
+ # full tasks may be large also in few numbers (e.g., with long logs)
+ max_page_bytes_full: PositiveInt = 10485760
@model_validator(mode="after")
</code_context>
<issue_to_address>
**FULL pages can exhaust memory**
When a deployment uses those defaults and concurrent FULL pages contain enough many-small-field tasks to approach the byte cap, `served_size` serializes each decoded task while the page retains its task dictionaries; for many-small-field tasks, the documented memory estimate reaches about seven times the 10 MiB default. Four concurrent requests can therefore exceed the chart’s 256 MiB limit and restart the app, disrupting requests.
Lower the default or chart byte limit, or otherwise ensure the configured cap and concurrency fit the app’s memory limit.
Also at `pro_tes/ga4gh/tes/task_runs.py:278`.
</issue_to_address>Linked issues
#455 fix: bound FULL task pages by size in bytes · 4 of 4 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Bound FULL pages by configurable max_page_bytes_full, default 10 MiB | ✅ Met | The setting defaults to 10485760 bytes and the listing code counts each FULL task against the response-body size. |
| 2 | Always include at least one task and continue next_page_token after the last returned task | ✅ Met | The byte limit is enforced only after a task has been added, and the token is set to the ID of the last task served when the next task would exceed the limit. |
| 3 | Keep max_page_size_full in effect | ✅ Met | FULL page sizes remain capped by max_page_size_full; the byte limit is applied in addition to that cap. |
| 4 | Add unit and integration tests, document the setting and chart memory notes, and include upgrade notes | ✅ Met | The change adds configuration and API tests, documents the setting and memory estimates, updates the chart notes, and adds an upgrade note. |
Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: pro_tes/config_models.py:194
With the app default of 10 MiB, pages of tasks with many small fields take up to about 70 MiB per request, so 4 threads could exceed the chart's memory limit of 256 MiB. Set 4 MiB in the chart, next to max_page_size_full, and give the memory estimate in values.yaml. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Pages of
GET /tasks?view=FULLare now also bounded by size, the last open item of #416:custom.controllers.list_tasks.max_page_bytes_full(default 10485760, i.e., 10 MiB), next tomax_page_size_full.next_page_tokencontinues after the last task served, so paging returns every task once.max_page_size_fullstill applies; other views are unchanged.served_size()counts the indented JSON plus the extra indentation of the nesting, and a test checks it against the real body.FULLare fetched one at a time (batch_size(1)), so the driver decodes no task beyond the end of a page.Closes #455
Docs
docs/configuration.md(Tasks): the new setting, and memory per request (about 3 times the bound plus one task for large texts, up to about 7 times for many small fields).docs/api.md:GET /tasksmentions the bound.docs/upgrading.md(To version 0.6.0): pages with large tasks hold fewer tasks; paging clients are unaffected.deployment/values.yamlanddeployment/README.md: the setting next tomax_page_size_fulland the memory limit.pro_tes/config.yaml: the setting and its comment.Verification
Test first:
test_list_tasks_page_bytes_fullandtest_list_tasks_page_bytes_one_taskfailed before the bound;test_list_tasks_served_sizeandtest_list_tasks_full_batchesfailed before the review fix.coverage run -m pytest(mongomock; chart tests with helm): 1750 passed, 11 skipped;coverage report100%.Against MongoDB 7.0 locally (
MONGODB_TEST_URI):tests/ga4gh/tes/test_server.py166 passed.ruff check/ruff format --check(0.17.3),mypy,ast-grep scan,semgrep --config=.semgrep: clean.mkdocs build --strict: OK.Review:
adversarial-reviewerandquality-reviewer. Fixed:Review round 2 (
adversarial-reviewer): one low, fixed: the memory per request is an estimate, not a bound (up to about 7 times the response size for tasks with many small fields); the docs now say so.Sourcery: memory with 4 threads and the default could exceed the chart's 256 MiB; fixed by setting
max_page_bytes_fullto 4 MiB in the chart (tests/test_chart.py), with the estimate invalues.yaml,deployment/README.md, Configuration and the upgrade notes. Chart, config example and README tests: 284 passed.CI: all checks passed (
CI passed).Declined review findings
None.
Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Limit
FULLtask-list pages by response size as well as task count without changing other views or pagination completeness.New Features:
FULLtask-list pages by both task count and response-body size, while preserving complete token-based pagination and at least one task per page.Enhancements:
FULLtasks incrementally and size pages according to their actual indented JSON representation.Deployment:
max_page_bytes_fullto 4 MiB to keepFULLpages within the chart memory limit.Documentation:
Tests:
FULL-view fetching.