You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by paul-rogers <gi...@git.apache.org> on 2017/05/12 18:02:51 UTC
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
GitHub user paul-rogers opened a pull request:
https://github.com/apache/drill/pull/833
DRILL-5496: Fix for failed Hive connection
If the Hive server restarts, Drill either hangs or continually reports errors when retrieving schemas. The problem is that the Hive plugin tries to handle connection failures, but does not do so correctly for the secure connection case. The problem is complex, see DRILL-5496 for details.
This is a workaround: we discard the entire Hive schema cache when we
encounter an unhandled connection exception, then we rebuild a new one.
This is not a proper fix; for that we'd have to restructure the code.
This will, however, solve the immediate problem until we do the needed
restructuring.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/paul-rogers/drill DRILL-5496
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/drill/pull/833.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #833
----
commit 10863164edfe8ef92058dd6b8568e9268d9b6978
Author: Paul Rogers <pr...@maprtech.com>
Date: 2017-05-12T18:01:54Z
DRILL-5496: Fix for failed Hive connection
If the Hive server restarts, Drill either hangs or continually reports
errors when retrieving schemas. The problem is that the Hive plugin
tries to handle connection failures, but does not do so correctly for
the secure connection case. The problem is complex, see DRILL-5496 for
details.
This is a workaround: we discard the entire Hive schema cache when we
encounter an unhandled connection exception, then we rebuild a new one.
This is not a proper fix; for that we'd have to restructure the code.
This will, however, solve the immediate problem until we do the needed
restructuring.
----
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers closed the pull request at:
https://github.com/apache/drill/pull/833
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
Posted by sudheeshkatkam <gi...@git.apache.org>.
Github user sudheeshkatkam commented on a diff in the pull request:
https://github.com/apache/drill/pull/833#discussion_r116329234
--- Diff: contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/schema/HiveSchemaFactory.java ---
@@ -105,6 +105,20 @@ private boolean needToImpersonateReadingData() {
return isDrillImpersonationEnabled && isHS2DoAsSet;
}
+ /**
+ * Close this schema factory in preparation for retrying. Attempt to close
+ * connections, but just ignore any errors.
+ */
+
+ public void close() {
--- End diff --
Unused method?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/833#discussion_r116559151
--- Diff: contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/schema/HiveSchemaFactory.java ---
@@ -105,6 +105,20 @@ private boolean needToImpersonateReadingData() {
return isDrillImpersonationEnabled && isHS2DoAsSet;
}
+ /**
+ * Close this schema factory in preparation for retrying. Attempt to close
+ * connections, but just ignore any errors.
+ */
+
+ public void close() {
+ try {
+ processUserMetastoreClient.close();
+ } catch (Exception e) { }
--- End diff --
No real need. The problem is not that the close fails for whatever reason, it is higher up in the food chain.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #833: DRILL-5496: Fix for failed Hive connection
Posted by amansinha100 <gi...@git.apache.org>.
Github user amansinha100 commented on the issue:
https://github.com/apache/drill/pull/833
Merged to master. @paul-rogers pls close the PR.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #833: DRILL-5496: Fix for failed Hive connection
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/833
Closing PR as change was merged into master (but without the magic commit message that closes this automagically.)
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
Posted by sudheeshkatkam <gi...@git.apache.org>.
Github user sudheeshkatkam commented on a diff in the pull request:
https://github.com/apache/drill/pull/833#discussion_r116541621
--- Diff: contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/schema/HiveSchemaFactory.java ---
@@ -105,6 +105,20 @@ private boolean needToImpersonateReadingData() {
return isDrillImpersonationEnabled && isHS2DoAsSet;
}
+ /**
+ * Close this schema factory in preparation for retrying. Attempt to close
+ * connections, but just ignore any errors.
+ */
+
+ public void close() {
+ try {
+ processUserMetastoreClient.close();
+ } catch (Exception e) { }
+ try {
+ metaStoreClientLoadingCache.invalidateAll();
+ } catch (Exception e) { }
--- End diff --
Log a warning message?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #833: DRILL-5496: Fix for failed Hive connection
Posted by sudheeshkatkam <gi...@git.apache.org>.
Github user sudheeshkatkam commented on the issue:
https://github.com/apache/drill/pull/833
Please open another ticket to resolve the issues mentioned in the comments (and even better if the ticket number is included with the comments "\\ TODO(DRILL-XXXX): ... " 😃 ).
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #833: DRILL-5496: Fix for failed Hive connection
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/833
Added DRILL-5510. Revisit connection failure recovery in Hive storage plugin. Added comment as requested.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
Posted by sudheeshkatkam <gi...@git.apache.org>.
Github user sudheeshkatkam commented on a diff in the pull request:
https://github.com/apache/drill/pull/833#discussion_r116541521
--- 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 --
Log a warning message?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
Posted by sudheeshkatkam <gi...@git.apache.org>.
Github user sudheeshkatkam commented on a diff in the pull request:
https://github.com/apache/drill/pull/833#discussion_r116541601
--- Diff: contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/schema/HiveSchemaFactory.java ---
@@ -105,6 +105,20 @@ private boolean needToImpersonateReadingData() {
return isDrillImpersonationEnabled && isHS2DoAsSet;
}
+ /**
+ * Close this schema factory in preparation for retrying. Attempt to close
+ * connections, but just ignore any errors.
+ */
+
+ public void close() {
+ try {
+ processUserMetastoreClient.close();
+ } catch (Exception e) { }
--- End diff --
Log a warning message?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
Posted by paul-rogers <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/833#discussion_r116559428
--- Diff: contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/schema/HiveSchemaFactory.java ---
@@ -105,6 +105,20 @@ private boolean needToImpersonateReadingData() {
return isDrillImpersonationEnabled && isHS2DoAsSet;
}
+ /**
+ * Close this schema factory in preparation for retrying. Attempt to close
+ * connections, but just ignore any errors.
+ */
+
+ public void close() {
+ try {
+ processUserMetastoreClient.close();
+ } catch (Exception e) { }
+ try {
+ metaStoreClientLoadingCache.invalidateAll();
+ } catch (Exception e) { }
--- End diff --
See above.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #833: DRILL-5496: Fix for failed Hive connection
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:
https://github.com/apache/drill/pull/833
Squashed commits.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill issue #833: DRILL-5496: Fix for failed Hive connection
Posted by sudheeshkatkam <gi...@git.apache.org>.
Github user sudheeshkatkam commented on the issue:
https://github.com/apache/drill/pull/833
Could you squash commits into one?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] drill pull request #833: DRILL-5496: Fix for failed Hive connection
Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/833#discussion_r116533781
--- Diff: contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/schema/HiveSchemaFactory.java ---
@@ -105,6 +105,20 @@ private boolean needToImpersonateReadingData() {
return isDrillImpersonationEnabled && isHS2DoAsSet;
}
+ /**
+ * Close this schema factory in preparation for retrying. Attempt to close
+ * connections, but just ignore any errors.
+ */
+
+ public void close() {
--- 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---