corgy-w opened a new pull request, #11942: URL: https://github.com/apache/seatunnel/pull/11942
### What problem does this PR solve? `JobMetricsRunner` is scheduled by `ClientExecuteCommand` with an initial delay of `0`, so its **first run executes in the same second** the runner is constructed. `Duration.between(lastRunTime, now).getSeconds()` then returns `0`, and the average-rate calculation divides by zero: ```java long averageRead = (jobMetricsSummary.getSourceReadCount() - lastReadCount) / seconds; ``` The `ArithmeticException` is swallowed by the catch-all handler, so: - every job start logs a misleading warning (`Failed to get job metrics summary, it maybe first-run`), and - the first "Job Progress Information" print is **always silently dropped**. A system clock rollback can also produce a negative elapsed value and break the same calculation. ### What does this PR change? Clamp the elapsed seconds to at least `1` before computing the average rates (`Math.max(1L, ...)`), so the first run completes and prints progress info like any later run. ### How was it verified? - Added `testJobMetricsRunnerFirstRunDoesNotDivideByZero` and `testJobMetricsRunnerWhenMetricsNotReadyDoesNotThrow` to the existing `JobClientTest` (no new test class). - `JobClientTest`: 12/12 tests pass. - Confirmed the new regression test **fails against the pre-fix code** (`expected: <100> but was: <0>`, counters untouched after the swallowed exception) and passes with the fix. - `spotless:apply` clean. -- 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]
