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

        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.