zhang-arvin opened a new pull request, #7716: URL: https://github.com/apache/kyuubi/pull/7716
## What changes were proposed in this pull request? Fix operation state metrics being updated before the actual state transition is validated and applied, which makes metrics inaccurate when a transition fails or races (KYUUBI-7645). `KyuubiOperation#setState` previously: 1. Updated the metrics meters first (`OPERATION_STATE.<opType>.<oldState>` decremented, `OPERATION_STATE.<opType>.<newState>` and `OPERATION_STATE.<newState>` incremented). 2. Then delegated to `AbstractOperation#setState`, which calls `OperationState.validateTransition(state, newState)` and may throw for stale/invalid transitions. This caused two problems: - If `validateTransition` rejected the transition, the meters had already been updated, so metrics diverged from the real operation state. - Concurrent state transitions for the same operation were not an atomic transition-and-metrics-update sequence, so multiple threads could compute meter updates from the same stale old state. ## How was this patch tested? Rely on existing CI. The change reuses `AbstractOperation#withLockRequired` (the per-operation `ReentrantLock` already used by `cleanup`/`cancel`/`close`) to make the validate → update metrics → apply transition sequence atomic, and runs `OperationState.validateTransition` before any metrics update. Closes #7645 -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
