KAFKA-19672: Fix aggregate statistics parsing in producer performance… - #23315
Open
Alwaysgaurav1 wants to merge 1 commit into
Open
KAFKA-19672: Fix aggregate statistics parsing in producer performance…#23315Alwaysgaurav1 wants to merge 1 commit into
Alwaysgaurav1 wants to merge 1 commit into
Conversation
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.
Committer Checklist (fill in after opening the PR)
Description
In Apache Kafka system test benchmarks (
kafkatest/benchmarks/core/benchmark_test.py),ProducerPerformanceServicerunsorg.apache.kafka.tools.ProducerPerformanceand parses output from stdout. When tests completed or encountered early termination, they could fail withIndexError: list index out of rangeandUnable to parse aggregate performance statistics on node %d.This PR fixes multiple related issues identified in KAFKA-19672:
parse_stats(line)handling of window lines:ProducerPerformance.javaemits periodic window metrics (printWindow()) with 4 comma-separated values, whereas the aggregate summary (printTotal()) emits 8 values including percentiles (50th,95th,99th,99.9th).parse_stats(line)accessedparts[4]throughparts[7]unconditionally, throwingIndexErrorwhen encountering window lines. This brokeself.intermediate_statsaccumulation and failed whenever a window line was evaluated as the final stat.parse_statsto parse 4-element window stat lines gracefully and only include percentile fields when present (len(parts) >= 8).Accurate total statistics tracking:
last = linefor every line inSTDOUT_CAPTURE, the parsing loop now tracks lines containinglatency_50th_ms, ensuring extraneous lines (such as--print-metricstables, log statements, or trailing empty lines) do not overwrite the aggregate results.intermediate_stats=True, window stats are properly collected intoself.stats[idx-1].Stderr diagnostics on failure:
STDERR_CAPTUREis read and attached to the raisedExceptionto surface the root cause immediately rather than obscuring it with a parse failure.Suppress late window reporting in
ProducerPerformance.java:this.suppressPrint = true;inStats.printTotal(). This ensures that callbacks or shutdown flushes occurring after the total report has been printed do not emit trailing window reports.testSuppressPrintAfterPrintTotalinProducerPerformanceTest.java.Hardened
ConsumerPerformanceService&ShareConsumerPerformanceService:Testing
./gradlew :tools:checkstyleMain :tools:checkstyleTest :tools:spotbugsMain :tools:test --tests "org.apache.kafka.tools.ProducerPerformanceTest"(all 43 tests passed cleanly).