Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-531

Cancel of result set is incorrect/excesive

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.3, 2.1.1, 1.6.4
    • Fix Version/s: 2.2.0, 1.7.0
    • Component/s: Other
    • Labels:
      None

      Description

      Starting with 1.6.X, when a statement is closed, it has a result set and streaming is enabled, a kill command is sent out. That killed our application since we have a large scale application with hundreds of processes. cancelCurrentQuery creates a new connection and sends a kill command. If a new connection is created for every select, there are thousands of sockets left in TIMED_WAIT and the server cannot create new connections.

      This should be done in a dedicated, pooled connection. In addition to that, the code should check if the result set was already consumed and skip kill since there will be nothing to do anyway. In this case, even if a new connection is done, it will be done in 0.01% of the cases where the app abourts the ResultSet.

      public void close() throws SQLException {
              lock.lock();
              try {
                  closed = true;
       
                  if (results.getFetchSize() != 0) {
                      if (options.killFetchStmtOnClose) {
                          try {
                              protocol.cancelCurrentQuery();
                              skipMoreResults();
                          } catch (SQLException sqle) {
                              //eat exception
                          } catch (IOException sqle) {
                              //eat exception
                          }
                      } else skipMoreResults();
                  }
       
                  results.close();
                  protocol = null;
       
                  if (connection == null || connection.pooledConnection == null
                          || connection.pooledConnection.statementEventListeners.isEmpty()) {
                      return;
                  }
                  connection.pooledConnection.fireStatementClosed(this);
              } finally {
                  lock.unlock();
              }
          }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              diego dupin Diego Dupin
              Reporter:
              adrian.tarau Adrian Tarau
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: