[ 
https://issues.apache.org/jira/browse/IGNITE-13020?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

JiajunYang updated IGNITE-13020:
--------------------------------
    Description: 
Ignite throws sql exception sometimes while do ddl actions concurrently.The 
exception looks like:

java.sql.SQLException: Schema change operation failed: Thread got
 interrupted while trying to acquire table lock.
         at
 
org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:901)
         at
 
org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:231)
         at
 
org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:559)
         at
         ....
         at java.lang.Thread.run(Thread.java:748)

 

Here is one reproduce case:

1.Start a ignite without persitence enabled.

2.Use two threads to do ddl operations concurrently.

3.Each ddl opertion contains create table and create indices sqls.Send these 
sqls to ignite in one statement.

4.Do ddl operations repeatly and then wait for luck.U can add a system.exit 
when u get the exception.

 

Here is my  test code for u reference:

public class ConcurrentCreateTable {
     private static Connection conn;

    private static Connection conn1;

    public static void main(String[] args) throws Exception {

        initialize();
         new Thread(new Runnable() {

            @Override
             public void run() {
                 while (true) {
                     try (Statement stmt = conn.createStatement())

{                         stmt.execute(                             "CREATE 
TABLE IF NOT EXISTS city1(ID INTEGER,NAME VARCHAR,NAME1 VARCHAR ,PRIMARY 
KEY(ID)) WITH \"template=replicated\";"                                 + 
"CREATE INDEX IF NOT EXISTS city1_name ON city1(NAME);CREATE INDEX IF NOT 
EXISTS city1_name1 on city1(NAME1);");                         
stmt.execute("DROP TABLE IF EXISTS city1");                         
System.out.println("XXX");                     }

catch (SQLException e)

{                         e.printStackTrace();                     }
                 }
             }
         }).start();
         new Thread(new Runnable() {
 
             @Override
             public void run() {
                 while (true) {
                     try (Statement stmt = conn1.createStatement()) \{          
               stmt.execute(                             "CREATE TABLE IF NOT 
EXISTS city2(ID INTEGER,NAME VARCHAR, NAME1 VARCHAR ,PRIMARY KEY(ID)) WITH 
\"template=replicated\";"                                 + "CREATE INDEX IF 
NOT EXISTS city2_name ON city2(NAME);CREATE INDEX IF NOT EXISTS city2_name1 on 
city2(NAME1);");                         stmt.execute("DROP TABLE IF EXISTS 
city2");                         System.out.println("XXX");                     
} catch (SQLException e) \{                         e.printStackTrace();        
             }

                }
             }
         }).start();
         while (true)

{         }

    }

    private static void initialize() throws Exception

{         Class.forName(Config.IGNITE_DRIVER);         final Properties props = 
new Properties();         conn = DriverManager.getConnection(Config.IGNITE_URL, 
props);         conn1 = DriverManager.getConnection(Config.IGNITE_URL, props);  
   }

}

  was:
Ignite throws sql exception sometimes while do ddl actions concurrently.The 
exception looks like:

java.sql.SQLException: Schema change operation failed: Thread got
interrupted while trying to acquire table lock.
        at
org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:901)
        at
org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:231)
        at
org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:559)
        at
        ....
        at java.lang.Thread.run(Thread.java:748)

 

Here is one reproduce case:

1.Start a ignite without persitence enabled.

2.Use two threads to do ddl operations concurrently.

3.Each ddl opertion contains create table and create indices sqls.Send these 
sqls to ignite in one statement.

4.Do ddl operations repeatly and then wait for luck.U can add a system.exit 
when u get the exception.

 

Here is my code for  test code for u reference:

public class ConcurrentCreateTable {
    private static Connection conn;

    private static Connection conn1;

    public static void main(String[] args) throws Exception {

        initialize();
        new Thread(new Runnable() {

            @Override
            public void run() {
                while (true) {
                    try (Statement stmt = conn.createStatement()) {
                        stmt.execute(
                            "CREATE TABLE IF NOT EXISTS city1(ID
INTEGER,NAME VARCHAR,NAME1 VARCHAR ,PRIMARY KEY(ID)) WITH
\"template=replicated\";"
                                + "CREATE INDEX IF NOT EXISTS city1_name ON
city1(NAME);CREATE INDEX IF NOT EXISTS city1_name1 on city1(NAME1);");
                        stmt.execute("DROP TABLE IF EXISTS city1");
                        System.out.println("XXX");
                    } catch (SQLException e) {

                        e.printStackTrace();
                    }
                }
            }
        }).start();
        new Thread(new Runnable() {

            @Override
            public void run() {
                while (true) {
                    try (Statement stmt = conn1.createStatement()) {
                        stmt.execute(
                            "CREATE TABLE IF NOT EXISTS city2(ID
INTEGER,NAME VARCHAR, NAME1 VARCHAR ,PRIMARY KEY(ID)) WITH
\"template=replicated\";"
                                + "CREATE INDEX IF NOT EXISTS city2_name ON
city2(NAME);CREATE INDEX IF NOT EXISTS city2_name1 on city2(NAME1);");
                        stmt.execute("DROP TABLE IF EXISTS city2");
                        System.out.println("XXX");
                    } catch (SQLException e) {

                        e.printStackTrace();
                    }
                }
            }
        }).start();
        while (true) {

        }
    }

    private static void initialize() throws Exception {
        Class.forName(Config.IGNITE_DRIVER);
        final Properties props = new Properties();
        conn = DriverManager.getConnection(Config.IGNITE_URL, props);
        conn1 = DriverManager.getConnection(Config.IGNITE_URL, props);
    }
}


> Schema change operation failed: Thread got interrupted while trying to 
> acquire table lock.
> ------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-13020
>                 URL: https://issues.apache.org/jira/browse/IGNITE-13020
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 2.8
>            Reporter: JiajunYang
>            Priority: Major
>
> Ignite throws sql exception sometimes while do ddl actions concurrently.The 
> exception looks like:
> java.sql.SQLException: Schema change operation failed: Thread got
>  interrupted while trying to acquire table lock.
>          at
>  
> org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:901)
>          at
>  
> org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:231)
>          at
>  
> org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:559)
>          at
>          ....
>          at java.lang.Thread.run(Thread.java:748)
>  
> Here is one reproduce case:
> 1.Start a ignite without persitence enabled.
> 2.Use two threads to do ddl operations concurrently.
> 3.Each ddl opertion contains create table and create indices sqls.Send these 
> sqls to ignite in one statement.
> 4.Do ddl operations repeatly and then wait for luck.U can add a system.exit 
> when u get the exception.
>  
> Here is my  test code for u reference:
> public class ConcurrentCreateTable {
>      private static Connection conn;
>     private static Connection conn1;
>     public static void main(String[] args) throws Exception {
>         initialize();
>          new Thread(new Runnable() {
>             @Override
>              public void run() {
>                  while (true) {
>                      try (Statement stmt = conn.createStatement())
> {                         stmt.execute(                             "CREATE 
> TABLE IF NOT EXISTS city1(ID INTEGER,NAME VARCHAR,NAME1 VARCHAR ,PRIMARY 
> KEY(ID)) WITH \"template=replicated\";"                                 + 
> "CREATE INDEX IF NOT EXISTS city1_name ON city1(NAME);CREATE INDEX IF NOT 
> EXISTS city1_name1 on city1(NAME1);");                         
> stmt.execute("DROP TABLE IF EXISTS city1");                         
> System.out.println("XXX");                     }
> catch (SQLException e)
> {                         e.printStackTrace();                     }
>                  }
>              }
>          }).start();
>          new Thread(new Runnable() {
>  
>              @Override
>              public void run() {
>                  while (true) {
>                      try (Statement stmt = conn1.createStatement()) \{        
>                  stmt.execute(                             "CREATE TABLE IF 
> NOT EXISTS city2(ID INTEGER,NAME VARCHAR, NAME1 VARCHAR ,PRIMARY KEY(ID)) 
> WITH \"template=replicated\";"                                 + "CREATE 
> INDEX IF NOT EXISTS city2_name ON city2(NAME);CREATE INDEX IF NOT EXISTS 
> city2_name1 on city2(NAME1);");                         stmt.execute("DROP 
> TABLE IF EXISTS city2");                         System.out.println("XXX");   
>                   } catch (SQLException e) \{                         
> e.printStackTrace();                     }
>                 }
>              }
>          }).start();
>          while (true)
> {         }
>     }
>     private static void initialize() throws Exception
> {         Class.forName(Config.IGNITE_DRIVER);         final Properties props 
> = new Properties();         conn = 
> DriverManager.getConnection(Config.IGNITE_URL, props);         conn1 = 
> DriverManager.getConnection(Config.IGNITE_URL, props);     }
> }



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to