فهرست منبع

HUE-2251 [impala] Support query timeout

If QUERY_TIMEOUT_S > 0, the query will be timed out (i.e. cancelled) if Impala does not do any work
(compute or send back results) for that query within QUERY_TIMEOUT_S seconds.
Romain Rigaux 11 سال پیش
والد
کامیت
928b35e

+ 3 - 2
apps/beeswax/src/beeswax/server/dbms.py

@@ -65,7 +65,7 @@ def get(user, query_server=None):
 def get_query_server_config(name='beeswax', server=None):
   if name == 'impala':
     from impala.conf import SERVER_HOST as IMPALA_SERVER_HOST, SERVER_PORT as IMPALA_SERVER_PORT, \
-        IMPALA_PRINCIPAL, IMPERSONATION_ENABLED, QUERYCACHE_ROWS
+        IMPALA_PRINCIPAL, IMPERSONATION_ENABLED, QUERYCACHE_ROWS, QUERY_TIMEOUT_S
 
     query_server = {
         'server_name': 'impala',
@@ -73,7 +73,8 @@ def get_query_server_config(name='beeswax', server=None):
         'server_port': IMPALA_SERVER_PORT.get(),
         'principal': IMPALA_PRINCIPAL.get(),
         'impersonation_enabled': IMPERSONATION_ENABLED.get(),
-        'querycache_rows': QUERYCACHE_ROWS.get()
+        'querycache_rows': QUERYCACHE_ROWS.get(),
+        'QUERY_TIMEOUT_S': QUERY_TIMEOUT_S.get(),
     }
   else:
     kerberos_principal = hive_site.get_hiveserver2_kerberos_principal(HIVE_SERVER_HOST.get())

+ 6 - 0
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -516,6 +516,9 @@ class HiveServerClient:
 
 
   def execute_statement(self, statement, max_rows=1000, configuration={}):
+    if self.query_server['server_name'] == 'impala' and self.query_server['QUERY_TIMEOUT_S'] > 0:
+      configuration['QUERY_TIMEOUT_S'] = str(self.query_server['QUERY_TIMEOUT_S'])
+
     req = TExecuteStatementReq(statement=statement.encode('utf-8'), confOverlay=configuration)
     res = self.call(self._client.ExecuteStatement, req)
 
@@ -523,6 +526,9 @@ class HiveServerClient:
 
 
   def execute_async_statement(self, statement, confOverlay):
+    if self.query_server['server_name'] == 'impala' and self.query_server['QUERY_TIMEOUT_S'] > 0:
+      confOverlay['QUERY_TIMEOUT_S'] = str(self.query_server['QUERY_TIMEOUT_S'])
+
     req = TExecuteStatementReq(statement=statement.encode('utf-8'), confOverlay=confOverlay, runAsync=True)
     res = self.call(self._client.ExecuteStatement, req)
 

+ 8 - 0
apps/impala/src/impala/conf.py

@@ -69,6 +69,14 @@ CLOSE_QUERIES = Config(
   default=True
 )
 
+QUERY_TIMEOUT_S = Config(
+  key="query_timeout_s",
+  help=_t("If QUERY_TIMEOUT_S > 0, the query will be timed out (i.e. cancelled) if Impala does not do any work"
+          " (compute or send back results) for that query within QUERY_TIMEOUT_S seconds."),
+  type=int,
+  default=600
+)
+
 
 def config_validator(user):
   # dbms is dependent on beeswax.conf (this file)

+ 4 - 0
desktop/conf.dist/hue.ini

@@ -812,6 +812,10 @@
   # This will free all the query resources in Impala, but also make its results inaccessible.
   ## close_queries=true
 
+  # If QUERY_TIMEOUT_S > 0, the query will be timed out (i.e. cancelled) if Impala does not do any work
+  # (compute or send back results) for that query within QUERY_TIMEOUT_S seconds.
+  ## query_timeout_s=600
+
 
 ###########################################################################
 # Settings to configure HBase Browser

+ 4 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -819,6 +819,10 @@
   # This will free all the query resources in Impala, but also make its results inaccessible.
   ## close_queries=true
 
+  # If QUERY_TIMEOUT_S > 0, the query will be timed out (i.e. cancelled) if Impala does not do any work
+  # (compute or send back results) for that query within QUERY_TIMEOUT_S seconds.
+  ## query_timeout_s=600
+
 
 ###########################################################################
 # Settings to configure HBase Browser