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

closeResultSet takes a very long time when the operation is aborted after 1%

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Done
    • None
    • N/A
    • JDBC compatibility
    • None
    • 11.8.5-MariaDB-deb12
      mariadb-java-client-3.5.7.jar
      java21

    Description

      When executing a SELECT over the entire table and terminating the reading after approximately 1% of the rows, the close ResultSet operation takes an unexpectedly long time to complete.

      XsvRdbTestInteger|CREATE TABLE `XsvRdbTestInteger` (
        `RtnID` int(11) NOT NULL AUTO_INCREMENT,
        `RtmID` int(11) NOT NULL,
        `RtnInteger` int(11) DEFAULT NULL,
        PRIMARY KEY (`RtnID`),
        KEY `IdxFkRtnRdb` (`RtmID`)
      ) ENGINE=InnoDB AUTO_INCREMENT=16376618 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
      

      Table contains 10.000.000 rows

      Test Java Code

      long executeQueryDur = 0;
      long closeResultSetDur = 0;
      long totalTime = -System.currentTimeMillis();
       
      try (final Statement stmt =
      		con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT)) {
      	if (_fetchSize != null) {
      		stmt.setFetchSize(_fetchSize.intValue());
      	}
      	executeQueryDur = -System.currentTimeMillis();
      	try (final ResultSet rs = stmt.executeQuery("SELECT RtnID,RtmID,RtnInteger FROM XsvRdbTestInteger")) {
      		executeQueryDur += System.currentTimeMillis();
      		int step = 0;
      		while (rs.next()) {
      			step++;
      			if (_maxRows != null && step > _maxRows.intValue()) {
      				_log4j.debug("### abbruch {}/{}, fetchSize {}", step, total, _fetchSize);
      				break;
      			}
      		}
      		closeResultSetDur = -System.currentTimeMillis();
      	}
      	closeResultSetDur += System.currentTimeMillis();
      }
      totalTime += System.currentTimeMillis();
       
      final NumberFormat nf = NumberFormat.getInstance(Locale.GERMANY);
      _log4j.info("totalTime=" + totalTime + " ms, executeQuery=" + executeQueryDur + " ms, closeResultSet=" + closeResultSetDur
      		+ " ms, fetchSize=" + (_fetchSize == null ? "not set" : nf.format(_fetchSize)) + ", interrupt after " + nf.format(_maxRows)
      		+ " rows, " + nf.format(total) + " rows in table");
      

      totalTime ms executeQuery ms closeResultSet ms fetchSize interrupt after rows rows in table
      3758 2 3743 100 1.000 10.000.000
      3709 3 3705 1.000 1.000 10.000.000
      3698 7 3691 10.000 1.000 10.000.000
      4090 58 4031 100.000 1.000 10.000.000
      3607 422 3184 1.000.000 1.000 10.000.000
      3766 3765 0 10.000.000 1.000 10.000.000
      3872 3870 0 100.000.000 1.000 10.000.000
      3840 3838 0 not set 1.000 10.000.000
      3461 2 3387 100 100.000 10.000.000
      3579 3 3518 1.000 100.000 10.000.000
      3710 5 3657 10.000 100.000 10.000.000
      3803 49 3722 100.000 100.000 10.000.000
      3718 387 3331 1.000.000 100.000 10.000.000
      3778 3778 0 10.000.000 100.000 10.000.000
      3899 3897 0 100.000.000 100.000 10.000.000
      3868 3862 0 not set 100.000 10.000.000

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            svh Stefan van Hasselt
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.