KAFKA-9700:Fix negative estimatedCompressionRatio issue#8285
KAFKA-9700:Fix negative estimatedCompressionRatio issue#8285ijuma merged 7 commits intoapache:trunkfrom
Conversation
There are cases that currentEstimation is smaller than COMPRESSION_RATIO_IMPROVING_STEP and it will get negative estimatedCompressionRatio,which leads to misjudgment about if there is no room and MESSAGE_TOO_LARGE might occur. Change-Id: I0932a2a6ca669f673ab5d862d3fe7b2bb6d96ff6 Signed-off-by: Jiamei Xie <jiamei.xie@arm.com>
ijuma
left a comment
There was a problem hiding this comment.
Thanks for the PR. Can we please add a test?
|
@ijuma I tracked this issue because of MESSAGE_TOO_LARGE by running command |
There are cases that currentEstimation is smaller than COMPRESSION_RATIO_IMPROVING_STEP and it will get negative estimatedCompressionRatio,which leads to misjudgment about if there is no room and MESSAGE_TOO_LARGE might occur. Change-Id: I0932a2a6ca669f673ab5d862d3fe7b2bb6d96ff6 Signed-off-by: Jiamei Xie <jiamei.xie@arm.com>
|
@ijuma A test has been added. Please review it. Thanks. |
|
ok to test |
ijuma
left a comment
There was a problem hiding this comment.
Thanks for the test. A few comments below.
| // 2. currentEstimation < observedRatio && (currentEstimation + COMPRESSION_RATIO_DETERIORATE_STEP) > observedRatio | ||
| // 3. currentEstimation > observedRatio && (currentEstimation - COMPRESSION_RATIO_IMPROVING_STEP) > observedRatio | ||
| // 4. currentEstimation > observedRatio && (currentEstimation - COMPRESSION_RATIO_IMPROVING_STEP) < observedRatio | ||
| // In all cases, updatedCompressionRatio shouldn't smaller than observedRatio |
There was a problem hiding this comment.
It seems like we are duplicating a lot of the logic of the code in this comment. This is likely to get stale over time. Can we make the comment more concise and refer to the non test code for more detail?
| new EstimationsObservedRatios(0.8f, 0.84f, 0.84f), | ||
| new EstimationsObservedRatios(0.6f, 0.7f, 0.7f), | ||
| new EstimationsObservedRatios(0.6f, 0.4f, 0.4f), | ||
| new EstimationsObservedRatios(0.004f, 0.001f, 0.001f) |
There was a problem hiding this comment.
It seems that expected is always the same as observed? If so, why do we have 3 parameters instead of 2?
| // 3. currentEstimation > observedRatio && (currentEstimation - COMPRESSION_RATIO_IMPROVING_STEP) > observedRatio | ||
| // 4. currentEstimation > observedRatio && (currentEstimation - COMPRESSION_RATIO_IMPROVING_STEP) < observedRatio | ||
| // In all cases, updatedCompressionRatio shouldn't smaller than observedRatio | ||
| EstimationsObservedRatios[] currentEstimationsObservedRatios = new EstimationsObservedRatios[] { |
There was a problem hiding this comment.
If we use a List, we should be able to simplify the logic below by using an enhanced for loop.
Signed-off-by: Jiamei Xie <jiamei.xie@arm.com>
ijuma
left a comment
There was a problem hiding this comment.
Thanks for update, a few minor comments below.
| estimationsObservedRatios.add(new EstimationsObservedRatios(0.8f, 0.84f)); | ||
| estimationsObservedRatios.add(new EstimationsObservedRatios(0.6f, 0.7f)); | ||
| estimationsObservedRatios.add(new EstimationsObservedRatios(0.6f, 0.4f)); | ||
| estimationsObservedRatios.add(new EstimationsObservedRatios(0.004f, 0.001f)); |
There was a problem hiding this comment.
Nit: this can be written more concisely by using Arrays.asList.
| estimationsObservedRatios.add(new EstimationsObservedRatios(0.004f, 0.001f)); | ||
| float updatedCompressionRatio; | ||
| for(EstimationsObservedRatios estimationsObservedRatio:estimationsObservedRatios) | ||
| { |
There was a problem hiding this comment.
Nit: this brace should be on the previous line.
|
ok to test |
|
retest this please |
|
ok to test |
1 similar comment
|
ok to test |
|
retest this please |
|
Hmm, looks like |
Signed-off-by: Jiamei Xie <jiamei.xie@arm.com>
|
@ijuma In my second commit, it was ">=". I am really sorry for my careless. |
|
retest this please |
|
retest this please |
|
One job passed and the other had a flaky test failure:
|
|
Merged to trunk and cherry picked to 2.5. |
There are cases where `currentEstimation` is less than `COMPRESSION_RATIO_IMPROVING_STEP` causing `estimatedCompressionRatio` to be negative. This, in turn, may result in `MESSAGE_TOO_LARGE`. Reviewers: Ismael Juma <ismael@juma.me.uk>
|
@jiameixie Quick question, were you seeing the MESSAGE_TOO_LARGE in the broker? |
|
@ijuma I saw MESSAGE_TOO_LARGE in producer client |
Integrated PR from apache/kafka: apache#8285
There are cases that currentEstimation is smaller than
COMPRESSION_RATIO_IMPROVING_STEP and it will get negative
estimatedCompressionRatio,which leads to misjudgment
about if there is no room and MESSAGE_TOO_LARGE might occur.
Change-Id: I0932a2a6ca669f673ab5d862d3fe7b2bb6d96ff6
Signed-off-by: Jiamei Xie jiamei.xie@arm.com
More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.
Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.
Committer Checklist (excluded from commit message)