Răsfoiți Sursa

HUE-5931 [impala] Simpler error message when the query expired

Romain Rigaux 8 ani în urmă
părinte
comite
06463b5

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

@@ -645,12 +645,10 @@ class HiveServerClient:
     session = None
 
     if not withMultipleSession:
-
       # Default behaviour: get one session
       session = Session.objects.get_session(self.user, self.query_server['server_name'])
 
     else:
-
       # Get 2 + n_sessions sessions and filter out the busy ones
       sessions = Session.objects.get_n_sessions(self.user, n=2 + n_sessions, application=self.query_server['server_name'])
       LOG.debug('%s sessions found' % len(sessions))

+ 3 - 1
desktop/libs/notebook/src/notebook/connectors/base.py

@@ -35,7 +35,9 @@ class SessionExpired(Exception):
   pass
 
 class QueryExpired(Exception):
-  pass
+  def __init__(self, message=None):
+    super(QueryExpired, self).__init__()
+    self.message = message
 
 class AuthenticationRequired(Exception):
   pass

+ 7 - 1
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -275,7 +275,13 @@ class HS2Api(Api):
     db = self._get_db(snippet)
 
     handle = self._get_handle(snippet)
-    results = db.fetch(handle, start_over=start_over, rows=rows)
+    try:
+      results = db.fetch(handle, start_over=start_over, rows=rows)
+    except QueryServerException, ex:
+      if re.search('(client inactivity)|(Invalid query handle)', str(ex)) and ex.message:
+        raise QueryExpired(message=ex.message)
+      else:
+        raise QueryError(ex)
 
     # No escaping...
     return {

+ 2 - 0
desktop/libs/notebook/src/notebook/decorators.py

@@ -84,6 +84,8 @@ def api_error_handler(func):
       response['status'] = -2
     except QueryExpired, e:
       response['status'] = -3
+      if e.message:
+        response['message'] = e.message
     except AuthenticationRequired, e:
       response['status'] = 401
     except ValidationError, e:

+ 30 - 22
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -917,6 +917,10 @@ var EditorViewModel = (function() {
       }
       else if (data.status == -3) { // Statement expired
         self.status('expired');
+        if (data.message) {
+          self.errors.push({message: data.message, line: null, col: null});
+          huePubSub.publish('editor.snippet.result.normal', self);
+        }
       }
       else if (data.status == -4) { // Operation timed out
         notebook.retryModalCancel = function () {
@@ -1249,28 +1253,32 @@ var EditorViewModel = (function() {
     self.isFetchingData = false;
     self.fetchResultData = function (rows, startOver) {
       if (! self.isFetchingData) {
-        startLongOperationTimeout();
-        self.isFetchingData = true;
-        logGA('fetchResult/' + rows + '/' + startOver);
-        $.post("/notebook/api/fetch_result_data", {
-          notebook: ko.mapping.toJSON(notebook.getContext()),
-          snippet: ko.mapping.toJSON(self.getContext()),
-          rows: rows,
-          startOver: startOver
-        }, function (data) {
-          stopLongOperationTimeout();
-          data = JSON.bigdataParse(data);
-          if (data.status == 0) {
-            self.loadData(data.result, rows);
-          } else {
-            self._ajaxError(data, function() {self.isFetchingData = false; self.fetchResultData(rows, startOver); });
-            $(document).trigger("renderDataError", {snippet: self});
-          }
-        }, 'text').fail(function (xhr, textStatus, errorThrown) {
-          $(document).trigger("error", xhr.responseText);
-        }).always(function () {
-          self.isFetchingData = false;
-        });
+        if( self.status() == 'available') {
+          startLongOperationTimeout();
+          self.isFetchingData = true;
+          logGA('fetchResult/' + rows + '/' + startOver);
+          $.post("/notebook/api/fetch_result_data", {
+            notebook: ko.mapping.toJSON(notebook.getContext()),
+            snippet: ko.mapping.toJSON(self.getContext()),
+            rows: rows,
+            startOver: startOver
+          }, function (data) {
+            stopLongOperationTimeout();
+            data = JSON.bigdataParse(data);
+            if (data.status == 0) {
+              self.loadData(data.result, rows);
+            } else {
+              self._ajaxError(data, function() {self.isFetchingData = false; self.fetchResultData(rows, startOver); });
+              $(document).trigger("renderDataError", {snippet: self});
+            }
+          }, 'text').fail(function (xhr, textStatus, errorThrown) {
+            $(document).trigger("error", xhr.responseText);
+          }).always(function () {
+            self.isFetchingData = false;
+          });
+        } else {
+          huePubSub.publish('editor.snippet.result.normal', self);
+        }
       }
     };