abstractdog opened a new pull request, #6962:
URL: https://github.com/apache/hive/pull/6962

   ### What changes were proposed in this pull request?
   When compilation fails, `SQLOperation.prepare()` now leaves the operation 
alone if it is already in a terminal state (TIMEDOUT, CANCELED, ...). The 
compile failure is the result of that cancellation, so it is logged as a 
warning instead of being reported as an error. `runQuery()` already handles 
failures during execution this way.
   
   ### Why are the changes needed?
   The `hive.query.timeout.seconds` timer is started in `prepare()`, before the 
query is compiled. If it fires while the query is still compiling:
   1. the operation moves to TIMEDOUT and the driver is closed, which makes the 
compilation fail;
   2. `prepare()` then sets the state to ERROR, and TIMEDOUT -> ERROR is an 
illegal transition.
   
   The client gets a generic `SQLException` instead of a `SQLTimeoutException`:
   ```
   org.apache.hive.service.cli.HiveSQLException: Illegal Operation state 
transition from TIMEDOUT to ERROR
   ```
   This shows up as a flaky 
`TestJdbcDriver2#testURLWithHiveQueryTimeoutSeconds` (and the other timeout 
tests) on slow or loaded hosts.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. A query that times out while it is compiling now fails with a 
`SQLTimeoutException` and the `Query timed out after N seconds` message (SQL 
state `HYT00`). Before, it failed with a generic `SQLException` about an 
illegal state transition.
   
   ### How was this patch tested?
   - New unit test, `TestSQLOperationQueryTimeout`. Its mocked driver blocks in 
`compileAndRespond()` until the timeout closes it, then fails, so the race 
happens every time. Without the fix, the test fails with the illegal transition 
error; with the fix, it passes.
   - `TestJdbcDriver2#testURLWithHiveQueryTimeoutSeconds` and 
`testQueryTimeout*` in a container limited to half a CPU (`docker run 
--cpus=0.5`): 4 of 4 runs failed without the fix, and 3 of 3 passed with it.
   - The whole `TestJdbcDriver2` class passes (110 tests).


-- 
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]

Reply via email to