You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Igor (Jira)" <ji...@apache.org> on 2023/04/12 10:16:00 UTC
[jira] [Commented] (IGNITE-19247) Replication is timed out
[ https://issues.apache.org/jira/browse/IGNITE-19247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17711287#comment-17711287 ]
Igor commented on IGNITE-19247:
-------------------------------
I had the same exception when tried to insert 1M rows into table.
{code:java}
java.sql.BatchUpdateException: IGN-REP-3 TraceId:a304ac50-7e43-4c02-93e6-a2ab5782c945 Replication is timed out [replicaGrpId=e7a7333f-1735-4c3d-870a-4f0411ee761f_part_5]
at org.apache.ignite.internal.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:124)
at lunigorn.ignite3test.Test.main(Test.java:37) {code}
To reproduce this erorr I used [project|https://github.com/Lunigorn/ignite3test/tree/rows-capacity-test]
Logs in attachment.
[^node_0.log.zip][^node_1.log.zip][^test.log]
> 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
> Reporter: Alexander Belyak
> Priority: Critical
> Labels: ignite-3
> Fix For: 3.0
>
> Attachments: node_0.log.zip, node_1.log.zip, test.log
>
>
> This is very basic acceptance test.
> Code below just create <TABLES> tables with <COLUMNS+1> columns (int key and varchar cols) and insert <ROWS> rows into each table (with SLEEP ms interval between operations, with <RETRY> attemps.
>
> {noformat}
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.PreparedStatement;
> import java.sql.ResultSet;
> 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 = 10;
> private static final String TABLE_NAME = "K";
> private static final int ROWS = 1000;
> private static final int TABLES = 10;
> private static final int BATCH_SIZE = 10;
> private static final int SLEEP = 30;
> private static final int RETRY = 10;
> private static String getCreateSql(String tableName) {
> StringBuilder sql = new StringBuilder("create table ").append(tableName).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 final void s() {
> if (SLEEP > 0) {
> try {
> Thread.sleep(SLEEP);
> } catch (InterruptedException e) {
> // NoOp
> }
> }
> }
> private static void createTables(Connection connection, String tableName) throws SQLException {
> try (Statement stmt = connection.createStatement()) {
> System.out.println("Creating " + tableName);
> stmt.executeUpdate("drop table if exists " + tableName );
> s();
> stmt.executeUpdate(getCreateSql(tableName));
> s();
> }
> }
> private static String getInsertSql(String tableName) {
> StringBuilder sql = new StringBuilder("insert into ").append(tableName).append(" values(?");
> for (int i = 0; i < COLUMNS; i++) {
> sql.append(", ?");
> }
> sql.append(")");
> return sql.toString();
> }
> private static void insertBatch(PreparedStatement ps) {
> int retryCounter = 0;
> while(retryCounter <= RETRY) {
> try {
> ps.executeBatch();
> return;
> } catch (SQLException e) {
> System.err.println(retryCounter + " error while executing " + ps + ":" + e);
> retryCounter++;
> }
> }
> }
> private static void insertData(Connection connection, String tableName) throws SQLException {
> long ts = System.currentTimeMillis();
> try (PreparedStatement ps = connection.prepareStatement(getInsertSql(tableName))) {
> 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;
> insertBatch(ps);
> ps.clearBatch();
> System.out.println("Batch " + BATCH_SIZE + " took " + (System.currentTimeMillis() - ts) + " to get " + i + " rows");
> s();
> ts = System.currentTimeMillis();
> }
> }
> if (batch > 0) {
> insertBatch(ps);
> ps.clearBatch();
> s();
> }
> }
> }
> private static int testData(Connection connection, String tableName) throws SQLException {
> try (Statement stmt = connection.createStatement();
> ResultSet rs = stmt.executeQuery("select count(*) from " + tableName);) {
> rs.next();
> int count = rs.getInt(1);
> int result = ROWS - count;
> if (result == 0) {
> System.out.println("Found " + count + " rows in " + tableName);
> } else {
> System.err.println("Found " + count + " rows in " + tableName + " instead of " + ROWS);
> }
> s();
> return result;
> }
> }
> public static void main(String[] args) throws SQLException {
> int lostRows = 0;
> try (Connection connection = DriverManager.getConnection(DB_URL)) {
> for (int i = 0; i < TABLES; i++) {
> String tableName = TABLE_NAME + i;
> createTables(connection, tableName);
> insertData(connection, tableName);
> lostRows += testData(connection, tableName);
> }
> }
> System.exit(lostRows);
> }
> }
> {noformat}
> And we can see some problems, like:
> 1) Replication timeout exception
> 2) Data loss
> even if there are only one node in the cluster, small number of columns, tables and rows and huge sleep between operations.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)