chennaji9 opened a new issue, #11280:
URL: https://github.com/apache/rocketmq/issues/11280
### Description
The batch benchmark producer
`example/src/main/java/org/apache/rocketmq/example/benchmark/BatchProducer.java`
reports incorrect statistics in two ways.
**1. One interrupted send is counted twice**
In the `catch (InterruptedException e)` block of the send thread, the
failure counters are incremented twice — once before the `Thread.sleep(3000)`
and once after:
```java
} catch (InterruptedException e) {
statsBenchmark.getSendRequestFailedCount().increment();
statsBenchmark.getSendMessageFailedCount().add(msgs.size());
try {
Thread.sleep(3000);
} catch (InterruptedException e1) {
}
statsBenchmark.getSendRequestFailedCount().increment();
statsBenchmark.getSendMessageFailedCount().add(msgs.size());
logger.error("[BENCHMARK_PRODUCER] Send Exception", e);
}
```
A single failed batch of size N is therefore reported as 2 failed requests
and 2N failed messages, which doubles the failure rate shown by the benchmark
report.
**2. Failed requests inflate the average success RT**
After the send result is obtained, the elapsed time is always added to the
success-time accumulator, even when the status is not `SEND_OK`:
```java
if (sendResult.getSendStatus() == SendStatus.SEND_OK) {
statsBenchmark.getSendRequestSuccessCount().increment();
statsBenchmark.getSendMessageSuccessCount().add(msgs.size());
} else {
statsBenchmark.getSendRequestFailedCount().increment();
statsBenchmark.getSendMessageFailedCount().add(msgs.size());
}
long currentRT = System.currentTimeMillis() - beginTimestamp;
statsBenchmark.getSendMessageSuccessTimeTotal().add(currentRT);
```
`printStats` divides `sendMessageSuccessTimeTotal` by the success counters
(`averageRT = (end[5] - begin[5]) / (end[1] - begin[1])`), so failed sends'
latency pollutes the reported average success RT. For example one success of 10
ms plus one failure of 90 ms reports an average success RT of 100 ms.
### Expected behavior
- An interrupted failed batch is counted exactly once.
- `sendMessageSuccessTimeTotal` only accumulates the latency of `SEND_OK`
sends so the reported average success RT reflects successful requests only.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]