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

rewriteBatchedStatements disables server side prepared statements in 2.7.5

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 3.4.1
    • None
    • None
    • None

    Description

      Without any configuration change prepared_stmt_count sharply increases when upgrading from 2.7.5 to 3.4.1, with performance impact.

      Additionally while `cachePrepStmts` is marked as removed in 3.0.0:
      https://mariadb.com/docs/connectors/mariadb-connector-j/about-mariadb-connector-j#removed-options

      The variable not only is still used internally but it seems that its user setting still affects behaviour, so not totally driven by internal behaviour.

      In 3.x code:

      Confirmation it's internally used:

      // src/main/java/org/mariadb/jdbc/Configuration.java
      public class Configuration {
        // ...
        // prepare
        private boolean cachePrepStmts = true;
        private int prepStmtCacheSize = 250;
        private boolean useServerPrepStmts = false;
        // ...
      }
      

      I might be mistaken but I don't see anywhere the variable is excluded from being read, this contradicts the documentation:

      Options being read from config:

          Properties propDesc = new Properties();
          try (InputStream inputStream =
              Driver.class.getClassLoader().getResourceAsStream("driver.properties")) {
            propDesc.load(inputStream);
          } catch (IOException io) {
            // eat
          }
      

      All values assigned to the array:

          List<DriverPropertyInfo> props = new ArrayList<>();
          for (Field field : Configuration.Builder.class.getDeclaredFields()) {
            if (!field.getName().startsWith("_")) {
              try {
        //...
      DriverPropertyInfo propertyInfo = new DriverPropertyInfo(field.getName(), value);
       //...       
       
         return props.toArray(new DriverPropertyInfo[0]);
        }
      

      Set to true if not provided:

      private void initializeAdditionalConfig(Builder builder) {
      //...
      this.cachePrepStmts = builder.cachePrepStmts == null || builder.cachePrepStmts;
      //...
      

      Attachments

        1. test_results_20250814_235905.log
          24 kB
        2. test_results_20250814_235834.log
          27 kB
        3. MariaDBPreparedStmtTest-2.java
          21 kB
        4. MariaDBPreparedStmtTest-1.java
          13 kB
        5. MariaDBPreparedStmtTest.java
          11 kB
        6. config-2.properties
          0.9 kB
        7. config-1.properties
          0.3 kB
        8. config.properties
          0.1 kB
        9. comparison_plot.png
          comparison_plot.png
          1.16 MB
        10. comparison_plot_with_rewrite_var.png
          comparison_plot_with_rewrite_var.png
          2.15 MB
        11. 3.4.2.test.0.2.0
          28 kB
        12. 3.4.2.test
          12 kB
        13. 2.7.12.test.0.2.0
          28 kB
        14. 2.7.12.test
          12 kB

        Issue Links

          Activity

            People

              diego dupin Diego Dupin
              claudio.nanni Claudio Nanni
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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