Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-25203

HiveQueryResultSet and client operation are not expected to be closed twice

    XMLWordPrintableJSON

Details

    Description

      While testing retry scenarios of HIVE-24786, we found that HiveQueryResultSet.close() is called twice, which is not expected. There are 2 different issues here:

      1. ResultSet should not handle Statement as in HiveQueryResultSet:

          if (this.statement != null && (this.statement instanceof HiveStatement)) {
            HiveStatement s = (HiveStatement) this.statement;
            s.closeClientOperation();
      

      The hiearchy of Connection(HiveConnection) -> Statement(HiveStatement) -> ResultSet(HiveQueryResultSet) should be respected in a sense that the parent can handle child but not the opposite way, only except a single case, where the state of the result set has an effect on statement's state, which is Statement.closeOnCompletion, which was introduced by HIVE-22698.
      The above logic was introduced by HIVE-4974. Its intention was to make children able to return their parents, but that doesn't mean they should handle their parents' lifecycle.

      2. Also, HiveStatement should close HiveQueryResultSet only if it's not already closed, so it would make sense to check ResultSet.isClosed() before closing. This is for the very same reason as another change above, to avoid duplicated close logic.

      Background: under normal circumstances, a close operation is idempotent, we should not worry about any side effects of calling it twice, but while testing HIVE-24786, we found strange issues where in case of a SocketTimeoutException, such code path was hit in the jdbc client, that made HiveStatement.closeClientOperation() to be called twice, and it led to a WARNING on HS2 side. This is not expected as the operation close is protected by stmtHandle != null check, but yet it ran twice. To avoid situations like this, cleaning up duplicated close calls would help.

      Attachments

        Issue Links

          Activity

            People

              abstractdog László Bodor
              abstractdog László Bodor
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h