You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Alexander Belyak (Jira)" <ji...@apache.org> on 2023/04/06 11:24:00 UTC

[jira] [Created] (IGNITE-19247) Replication is timed out

Alexander Belyak created IGNITE-19247:
-----------------------------------------

             Summary: Replication is timed out
                 Key: IGNITE-19247
                 URL: https://issues.apache.org/jira/browse/IGNITE-19247
             Project: Ignite
          Issue Type: Bug
          Components: general
    Affects Versions: 3.0
         Environment: Simple example:
{code:java}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

public class TimeoutExceptionReproducer {
    private static final String DB_URL = "jdbc:ignite:thin://172.24.1.2:10800";
    private static final int COLUMNS = 100;

    private static final String TABLE_NAME = "t1";
    private static final int ROWS = 100000;

    private static final int BATCH_SIZE = 100;

    private static String getCreateSql() {
        StringBuilder sql = new StringBuilder("create table ").append(TABLE_NAME).append(" (id int primary key");

        for (int i = 0; i < COLUMNS; i++) {
            sql.append(", col").append(i).append(" varchar NOT NULL");
        }

        sql.append(")");

        return sql.toString();
    }

    private static void createTable(Connection connection) throws SQLException {
        try (Statement stmt = connection.createStatement()) {
            stmt.executeUpdate("drop table if exists " + TABLE_NAME );
            stmt.executeUpdate(getCreateSql());
        }
    }

    private static String getInsertSql() {
        StringBuilder sql = new StringBuilder("insert into t1 values(?");

        for (int i = 0; i < COLUMNS; i++) {
            sql.append(", ?");
        }

        sql.append(")");

        return sql.toString();
    }

    private static void insertData(Connection connection) throws SQLException {
        long ts = System.currentTimeMillis();
        try (PreparedStatement ps = connection.prepareStatement(getInsertSql())) {
            int batch = 0;

            for (int i = 0; i < ROWS; i++) {
                ps.setInt(1, i);

                for (int j = 2; j < COLUMNS + 2; j++) {
                    ps.setString(j, "value" + i + "_" + j);
                }

                ps.addBatch();
                batch++;

                if (batch == BATCH_SIZE) {
                    batch = 0;
                    ps.executeBatch();
                    ps.clearBatch();
                    long nextTs = System.currentTimeMillis();
                    System.out.println("Batch " + BATCH_SIZE + " took " + (nextTs - ts) + " to get " + i + " rows");
                    ts = nextTs;
                }
            }

            if (batch > 0) {
                batch = 0;
                ps.executeBatch();
                ps.clearBatch();
            }
        }
    }

    public static void main(String[] args) throws SQLException {
        try (Connection connection = DriverManager.getConnection(DB_URL)) {
            createTable(connection);

            insertData(connection);
        }
    }
}
 {code}
lead to timeout exception:
{code:java}
Batch 100 took 4228 to get 2899 rows
Batch 100 took 5669 to get 2999 rows
Batch 100 took 3902 to get 3099 rows
Exception in thread "main" java.sql.BatchUpdateException: IGN-REP-3 TraceId:b2c2c9e5-b917-482e-91df-2e0576c443c7 Replication is timed out [replicaGrpId=76c2b69a-a2bc-4d16-838d-5aff014c6004_part_11]
    at org.apache.ignite.internal.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:124)
    at TimeoutExceptionReproducer.insertData(TimeoutExceptionReproducer.java:64)
    at TimeoutExceptionReproducer.main(TimeoutExceptionReproducer.java:84){code}
            Reporter: Alexander Belyak
             Fix For: 3.0






--
This message was sent by Atlassian Jira
(v8.20.10#820010)