gaoxq opened a new pull request, #6664: URL: https://github.com/apache/hive/pull/6664
## What changes were proposed in this pull request? When Direct SQL fails with a JDBC connection-level error, invalidate and shut down the RawStore cached in `HMSHandlerContext` instead of falling back to ORM with the same broken PersistenceManager/connection. The change: * preserves the original `SQLException` from `MetaStoreDirectSql.prepareTxn()`; * recognizes SQLState class `08` and JDBC connection exception subclasses; * removes the thread-local RawStore before shutdown; * wraps the failure as a JDO datastore error so `RetryingHMSHandler` can retry; * makes ObjectStore cleanup safe when an outer handler subsequently rolls back; * keeps the existing ORM fallback for non-connection Direct SQL failures. ## Why are the changes needed? After a transient metastore database communication failure, a handler thread can retain a closed connection through its cached PersistenceManager. HikariCP cannot replace that connection while the wrapper remains in use, so later RPCs on the same handler thread can repeatedly fail with `Connection is closed` until HMS is restarted. JIRA: https://issues.apache.org/jira/browse/HIVE-29584 ## How was this patch tested? * Added a regression test for SQLState `08S01` that verifies no ORM fallback, RawStore invalidation, preservation of the JDO-backed error, and safe outer transaction rollback. The test failed with an NPE before the cleanup fix and passes afterward. * `TestObjectStore#testDirectSqlConnectionErrorInvalidatesRawStore` * `TestObjectStore#testDirectSqlErrorMetrics` * `TestObjectStore#testNoJdoForUnrecoverableException` * `TestRetriesInRetryingHMSHandler#testWrappedMetaExceptionRetry` * `mvn -pl standalone-metastore/metastore-server -DskipTests checkstyle:check` -- 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]
