Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-6605

Multiple Clients Inserting Causing Error: Failed to read auto-increment value from storage engine

    XMLWordPrintable

Details

    Description

      I have a table partitioned by range created with the tokudb engine on mariadb 10.0.12. When I have one client inserting into this table everything works as expected. However, as soon as I have a second client inserting more data into this table I get the following error: Failed to read auto-increment value from storage engine. When I see the table status the Auto_increment value is 2049. My auto increment description is "id bigint not null auto_increment".

      I can reproduce this problem with the below table and Java client side code. Another tokudb user on the tokudb-user group performed the test on Percona Server 5.6, which did not fail: https://groups.google.com/forum/#!topic/tokudb-user/2pnjQxuuvUo

      CREATE TABLE `auto_inc_test` (
        `id` bigint(20) NOT NULL AUTO_INCREMENT,
        `time` bigint(20) NOT NULL,
        PRIMARY KEY (`time`,`id`)
      ) ENGINE=TokuDB AUTO_INCREMENT=1001 DEFAULT CHARSET=latin1 `compression`='tokudb_zlib'
       
      ALTER TABLE order_books partition by range (time) (
          partition p0 values less than (1507495611880)
      );

      public class MultipleClientsInsertingDataIntoPartitionedTokudbTable {
       
          public static final String INSERT_STATEMENT = "INSERT INTO test.auto_inc_test (time) values (?)";
       
          private final CountDownLatch countDownLatch;
       
          public MultipleClientsInsertingDataIntoPartitionedTokudbTable() {
              countDownLatch = new CountDownLatch(2);
          }
       
          public static void main(String[] args) throws InterruptedException {
              MultipleClientsInsertingDataIntoPartitionedTokudbTable multipleClientsInsertingDataIntoPartitionedTokudbTable = new MultipleClientsInsertingDataIntoPartitionedTokudbTable();
              multipleClientsInsertingDataIntoPartitionedTokudbTable.start();
          }
       
          private void start() throws InterruptedException {
              DataSource dataSource = createDataSource();
              new Thread(new InsertRunnable(dataSource)).start();
              new Thread(new InsertRunnable(dataSource)).start();
              countDownLatch.await();
          }
       
          private DataSource createDataSource() {
              String jdbcUrl = "jdbc:mysql://xxx.xxx.xxx.xxx/test?tcpNoDelay=true&tcpKeepAlive=true&rewriteBatchedStatements=true";
              String username = "user";
              String password = "password";
              MysqlDataSource mysqlDataSource = new MysqlDataSource();
              mysqlDataSource.setURL(jdbcUrl);
              mysqlDataSource.setUser(username);
              mysqlDataSource.setPassword(password);
              return mysqlDataSource;
          }
       
          private void insertData(DataSource dataSource) {
              try (Connection connection = dataSource.getConnection();
                      PreparedStatement preparedStatement = connection
                              .prepareStatement(INSERT_STATEMENT)) {
       
                  connection.setAutoCommit(false);
                  for (int i = 0; i < 1000; i++) {
                      preparedStatement.setLong(1, System.currentTimeMillis());
                      preparedStatement.addBatch();
                  }
                  preparedStatement.executeBatch();
       
              } catch (SQLException e) {
                  e.printStackTrace();
              }
          }
       
          private class InsertRunnable implements Runnable {
       
              private final DataSource dataSource;
       
              private InsertRunnable(DataSource dataSource) {
                  this.dataSource = dataSource;
              }
       
              @Override
              public void run() {
                  for (int i = 0; i < 1000; i++) {
                      insertData(dataSource);
                  }
       
                  countDownLatch.countDown();
              }
          }
      }

      Attachments

        Activity

          People

            serg Sergei Golubchik
            kp1dsq Can Can
            Votes:
            0 Vote for this issue
            Watchers:
            5 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.