-
Notifications
You must be signed in to change notification settings - Fork 23
Prevent max message cache size reaching zero by having a minimum of 1 message per worker after the round up #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses a potential edge case where the message cache size could be calculated as zero, leading to fetch failures. The fix ensures that each worker has at least one message in the cache while maintaining the existing round-up logic.
Key changes:
- Introduces a
Math.max()check to guarantee a minimum of 1 message per worker before applying concurrency multiplier - Refactors the rounding logic into a separate
#roundUpToNearestMultipleOfMaxBatchesSizemethod for better code organization - Updates CHANGELOG to document the fix
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/kafkajs/_consumer.js | Adds minimum message guarantee and extracts rounding logic into helper method |
| CHANGELOG.md | Documents the bug fix for low consumption rate scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ea75d1a to
9f624a5
Compare
9f624a5 to
2389348
Compare
having a minimum of 1 message per worker after the round up
2389348 to
aa9d606
Compare
lib/kafkajs/_consumer.js
Outdated
| 1, | ||
| // Messages needed for `#maxCacheSizePerWorkerMs` milliseconds of consumption | ||
| // per worker | ||
| Math.round( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use Math.ceil here instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, not a big change to always take the ceil given it's also rounding up to next multiple of maxBatchSize later
pranavrth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!.
Continuation of #418 with this different approach that allows to