Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/833#discussion_r116559073
--- Diff:
contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveStoragePlugin.java
---
@@ -95,8 +99,63 @@ public HiveScan getPhysicalScan(String userName,
JSONOptions selection, List<Sch
}
}
+ // Forced to synchronize this method to allow error recovery
+ // in the multi-threaded case. Can remove synchronized only
+ // by restructuring connections and cache to allow better
+ // recovery from failed secure connections.
+
@Override
- public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus
parent) throws IOException {
+ public synchronized void registerSchemas(SchemaConfig schemaConfig,
SchemaPlus parent) throws IOException {
+ try {
+ schemaFactory.registerSchemas(schemaConfig, parent);
+ return;
+
+ // Hack. We may need to retry the connection. But, we can't because
+ // the retry logic is implemented in the very connection we need to
+ // discard and rebuild. To work around, we discard the entire schema
+ // factory, and all its invalid connections. Very crude, but the
+ // easiest short-term solution until we refactor the code to do the
+ // job properly. See DRILL-5510.
+
+ } catch (Throwable e) {
+ // Unwrap exception
+ Throwable ex = e;
+ for (;;) {
+ // Case for failing on an invalid cached connection
+ if (ex instanceof MetaException ||
+ // Case for a timed-out impersonated connection, and
+ // an invalid non-secure connection used to get security
+ // tokens.
+ ex instanceof TTransportException) {
+ break;
+ }
+
+ // All other exceptions are not handled, just pass along up
+ // the stack.
+
+ if (ex.getCause() == null || ex.getCause() == ex) {
+ throw new DrillRuntimeException( "Unknown Hive error", e );
+ }
+ ex = ex.getCause();
+ }
+ }
+
+ // Build a new factory which will cause an all new set of
+ // Hive metastore connections to be created.
+
+ try {
+ schemaFactory.close();
+ } catch (Throwable t) {
+ // Ignore, we're in a bad state.
--- End diff --
Fixed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---