fix(taskiq): cap RedisStreamBroker maxlen at 10k entries - #40
Merged
Conversation
Prevents unbounded Taskiq stream growth that saturated prd Valkey at 1.50G (review stream alone held 6M entries). Trims on each XADD via taskiq-redis approximate maxlen. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Taskiq Redis stream broker configuration to cap stream growth by passing a bounded maxlen (default 10,000) and enabling approximate trimming, and exposes this as a configurable option on TaskiqPlugin.
Changes:
- Add
stream_maxlen(default10_000) toSchedulerComponent.configure()and passmaxlen/approximate=TruetoRedisStreamBroker. - Add
stream_maxlen(default10_000) toTaskiqPluginand forward it into the scheduler component configuration. - Add a unit test asserting the broker is constructed with
maxlen/approximate, and document the fix in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/units/fastapi_factory_utilities/core/plugins/taskiq_plugin/test_schedulers.py | Adds a unit test verifying stream_maxlen is forwarded into RedisStreamBroker(...). |
| src/fastapi_factory_utilities/core/plugins/taskiq_plugin/schedulers.py | Adds stream_maxlen config and applies maxlen + approximate=True to the Redis stream broker. |
| src/fastapi_factory_utilities/core/plugins/taskiq_plugin/plugins.py | Exposes stream_maxlen on TaskiqPlugin and wires it into scheduler configuration. |
| CHANGELOG.md | Adds a 6.5.2 changelog entry describing the Redis stream trimming behavior change. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+10
to
+16
| ## [6.5.2] - 2026-08-22 | ||
|
|
||
| ### Fixed | ||
|
|
||
| - Taskiq: pass ``maxlen=10_000`` (approximate) to ``RedisStreamBroker`` so | ||
| Valkey Taskiq streams are trimmed on publish instead of growing without bound. | ||
|
|
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
maxlen=10_000andapproximate=TruetoRedisStreamBrokerinSchedulerComponent.configure().stream_maxlenonTaskiqPlugin(default 10_000).Test plan
pytest tests/units/.../test_schedulers.pyv6.5.2after merge to publish to PyPIMade with Cursor