Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-1227

HS2 shell ^C sometimes closes the session rather than canceling the query

    XMLWordPrintableJSON

Details

    Description

      In Abdullah's HS2 shell patch, the ^C signal handler intends to cancel the active query:

        def __signal_handler(self, signal, frame):
          if not self.cursor._last_operation_active:
            return
          # Create a new connection to the impalad and cancel the query.
          try:
            # self.query_handle_closed = True
            print_to_stderr(ImpalaShell.CANCELLATION_MESSAGE)
            cursor = self.imp_conn.cursor(session_handle=self.cursor.session_handle)
            cursor._last_operation_active = self.cursor._last_operation_active
            cursor._last_operation_handle = self.cursor._last_operation_handle
            cursor._last_operation_string = self.cursor._last_operation_string
            cursor.cancel_operation()
            self.cursor._last_operation_active = False
            self._validate_database()
          except Exception, e:
            print_to_stderr("Failed to reconnect and close: %s" % str(e))
            # TODO: Add a retry here
      

      However, IMPALA-1178 shows that sometimes the shell is closing the session in response to ^C. It seems to happen if you press ^C immediately after issuing the query. If you wait a second and press ^C, then the query is cancelled correctly.

      localhost:21050] > select * from tpch.lineitem x, tpch.lineitem y where x.l_orderkey=y.l_orderkey;
      Query: select * from tpch.lineitem x, tpch.lineitem y where x.l_orderkey=y.l_orderkey
      <immediately press ctrl+C>
      ^CSession closed
      [localhost:21050] > select * from tpch.lineitem x, tpch.lineitem y where x.l_orderkey=y.l_orderkey;
      Query: select * from tpch.lineitem x, tpch.lineitem y where x.l_orderkey=y.l_orderkey
      Invalid session id
      [localhost:21050] > connect;
      Connected to localhost:21050
      Server version: Hive Server 2
      [localhost:21050] > select * from tpch.lineitem x, tpch.lineitem y where x.l_orderkey=y.l_orderkey;
      Query: select * from tpch.lineitem x, tpch.lineitem y where x.l_orderkey=y.l_orderkey
      <wait one second then press ctrl+C>
      ^C Cancelling Query
      

      Attachments

        Activity

          People

            ishaan Ishaan Joshi
            dhecht Daniel Hecht
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: