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

MariaDb bulk threads occupy full cpu(99%) while db connections broken

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • N/A
    • 1.8.0, 2.4.0
    • protocol
    • None

    Description

      Caused by: java.sql.SQLNonTransientConnectionException: (conn:59) Could not send query: 断开的管道 (Write failed)
      	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:156)
      	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:118)
      	at org.mariadb.jdbc.MariaDbStatement.executeBatchExceptionEpilogue(MariaDbStatement.java:295)
      	... 9 more
      Caused by: java.sql.SQLException: Could not send query: 断开的管道 (Write failed)
      	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.handleIoException(AbstractQueryProtocol.java:1488)
      	at org.mariadb.jdbc.internal.protocol.AbstractMultiSend.executeBatchStandard(AbstractMultiSend.java:290)
      	at org.mariadb.jdbc.internal.protocol.AbstractMultiSend.executeBatch(AbstractMultiSend.java:190)
      	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeBatch(AbstractQueryProtocol.java:371)
      	at org.mariadb.jdbc.MariaDbStatement.internalBatchExecution(MariaDbStatement.java:1268)
      	at org.mariadb.jdbc.MariaDbStatement.executeBatch(MariaDbStatement.java:1222)
      	... 8 more
      Caused by: java.net.SocketException: 断开的管道 (Write failed)
      	at java.net.SocketOutputStream.socketWrite0(Native Method)
      	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
      	at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
      	at org.mariadb.jdbc.internal.io.output.StandardPacketOutputStream.flushBuffer(StandardPacketOutputStream.java:103)
      	at org.mariadb.jdbc.internal.io.output.AbstractPacketOutputStream.flush(AbstractPacketOutputStream.java:157)
      	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol$2.sendCmd(AbstractQueryProtocol.java:383)
      	at org.mariadb.jdbc.internal.protocol.AbstractMultiSend.executeBatchStandard(AbstractMultiSend.java:229)
      	... 12 more
      

                      for (; status.sendSubCmdCounter < requestNumberByBulk; ) {
                          sendCmd(writer, results, parametersList, queries, paramCount, status, prepareResult);
                          status.sendSubCmdCounter++;
                          status.sendCmdCounter++;
       
                          if (futureReadTask == null) {
                              futureReadTask = new FutureTask<AsyncMultiReadResult>(new AsyncMultiRead(comStmtPrepare, status,
                                      protocol, false, this, paramCount,
                                      results, parametersList, queries, prepareResult));
                              AbstractQueryProtocol.readScheduler.execute(futureReadTask);
                          }
                      }
       
                      status.sendEnded = true;
      

      if the function sendCmd() throwes exception above while runing, the status.sendEnded couldn't be set to True, then the AsyncMultiRead thread will endless loop in while

              //ensure to not finished loop while all bulk has not been send
              while (!status.sendEnded || counter < status.sendSubCmdCounter) {
                  //read results for each send data
                  while (counter < status.sendSubCmdCounter) {
                      try {
                          protocol.getResult(results);
                      } catch (SQLException qex) {
                          if (asyncMultiReadResult.getException() == null) {
                              asyncMultiReadResult.setException(bulkSend.handleResultException(qex, results,
                                      parametersList, queries, counter, sendCmdInitialCounter, paramCount,
                                      asyncMultiReadResult.getPrepareResult()));
                          }
                      }
                      counter++;
       
                      if (Thread.currentThread().isInterrupted()) {
                          asyncMultiReadResult.setException(new SQLException("Interrupted reading responses ", INTERRUPTED_EXCEPTION.getSqlState(), -1));
                          break;
                      }
                  }
              }
      

      Attachments

        Issue Links

          Activity

            People

              diego dupin Diego Dupin
              zac860817 Zac
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.