You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Qingping <15...@qq.com> on 2018/11/26 07:15:35 UTC

(IF NOT EXISTS) in CREATE TABLE statement does not work

When testing Ignite 2.6.0 (2018-07-16), it was found that (IF NOT EXISTS) in
the CREATE TABLE statement did not work. code show as below:  
Class.forName("org.apache.ignite.IgniteJdbcThinDriver");    try (Connection
conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/"))    {       
try (Statement stmt = conn.createStatement())        {           
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS City(id LONG PRIMARY KEY,"                   
+ " name VARCHAR) WITH \"template=replicated\"");        }    }After the
first run is successful, an exception occurs again:Failed to execute SQL
query [reqId=0, req=JdbcQueryExecuteRequest [schemaName=PUBLIC,
pageSize=1024, maxRows=0, sqlQry=CREATE TABLE IF NOT EXISTS City(id LONG
PRIMARY KEY, name VARCHAR) WITH "template=replicated", args=[],
stmtType=UPDATE_STMT_TYPE]]at
org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor.convert(DdlStatementsProcessor.java:582)
at
org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor.runDdlStatement(DdlStatementsProcessor.java:511)
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.doRunPrepared(IgniteH2Indexing.java:1736)
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.querySqlFields(IgniteH2Indexing.java:1671)
at
org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:2035)
at
org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:2030)
at
org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2578)
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.querySqlFields(GridQueryProcessor.java:2044)
at
org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.executeQuery(JdbcRequestHandler.java:456)
at
org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:203)
at
org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:160)
at
org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:44)
at
org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
at
org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
at
org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
at
org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)	at
java.lang.Thread.run(Unknown Source)



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: (IF NOT EXISTS) in CREATE TABLE statement does not work

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

This is a well-known problem:
https://issues.apache.org/jira/browse/IGNITE-8060 (and friends)

Unfortunately there's no schedule for a fix.

Regards,
-- 
Ilya Kasnacheev


пн, 26 нояб. 2018 г. в 12:08, Qingping <15...@qq.com>:

> After many tests, I found that if I first set up an Ignite client node and
> then use ("jdbc:ignite:thin://127.0.0.1/") as the JDBC connection URL,
> various problems will occur, but if similar (
> "jdbc:ignite:thin://192.168.0.138/") The pure JDBC method that connects
> directly to the target Ignite cluster will not cause problems. The sample
> code for the problem is as follows:
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: (IF NOT EXISTS) in CREATE TABLE statement does not work

Posted by Qingping <15...@qq.com>.
After many tests, I found that if I first set up an Ignite client node and
then use ("jdbc:ignite:thin://127.0.0.1/") as the JDBC connection URL,
various problems will occur, but if similar (
"jdbc:ignite:thin://192.168.0.138/") The pure JDBC method that connects
directly to the target Ignite cluster will not cause problems. The sample
code for the problem is as follows:




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: (IF NOT EXISTS) in CREATE TABLE statement does not work

Posted by Qingping <15...@qq.com>.
Start a single instance Ignite server node locally, then connect this Ignite
cluster and run the previous test code, run successfully; then connect the
original distributed three-node Ignite cluster again, the test code also
runs successfully, what is the reason? Will the Ignite client buffer some
information locally?

View the service node logs of the distributed three-node Ignite cluster and
report no related errors.

The test code that was not displayed in the previous reply is as follows:





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: (IF NOT EXISTS) in CREATE TABLE statement does not work

Posted by Qingping <15...@qq.com>.
The problem has been re-described under another topic: some cases (IF NOT
EXISTS) in the CREATE TABLE statement does not work
<http://apache-ignite-users.70518.x6.nabble.com/some-cases-IF-NOT-EXISTS-in-the-CREATE-TABLE-statement-does-not-work-td25391.html>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: (IF NOT EXISTS) in CREATE TABLE statement does not work

Posted by Qingping <15...@qq.com>.
Start a single instance Ignite server node locally, then connect this Ignite
cluster and run the previous test code, run successfully; then connect the
original distributed three-node Ignite cluster again, the test code also
runs successfully, what is the reason? Will the Ignite client buffer some
information locally?View the service node logs of the distributed three-node
Ignite cluster and report no related errors.The test code that was not
displayed in the previous reply is as follows:		try		{		
Ignition.setClientMode(true);			IgniteConfiguration cfg = new
IgniteConfiguration();			cfg.setIgniteInstanceName("IgniteTest-Client");		
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();		
ipFinder.setAddresses(Arrays.asList("192.168.0.219", "192.168.0.220",
"192.168.0.221"));			TcpDiscoverySpi spi = new TcpDiscoverySpi();		
spi.setIpFinder(ipFinder);			cfg.setDiscoverySpi(spi);			try (Ignite ignite
= Ignition.start(cfg))			{			
Class.forName("org.apache.ignite.IgniteJdbcThinDriver");				try (Connection
conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/"))				{				
try (Statement stmt = conn.createStatement())					{					
stmt.executeUpdate("DROP TABLE IF EXISTS City");					
stmt.executeUpdate("DROP TABLE IF EXISTS Person");						// Create table
based on REPLICATED template.						stmt.executeUpdate("CREATE TABLE IF NOT
EXISTS City(id LONG PRIMARY KEY, name VARCHAR) "								+ "WITH
\"template=replicated\"");						// Create table based on PARTITIONED
template with one backup.						stmt.executeUpdate("CREATE TABLE IF NOT
EXISTS Person ( id LONG, name VARCHAR, city_id LONG,  PRIMARY KEY (id,
city_id)) "								+ "WITH \"backups=1, affinityKey=city_id\"");						//
Create an index on the City table.						stmt.executeUpdate("CREATE INDEX IF
NOT EXISTS idx_city_name ON City (name)");						// Create an index on the
Person table.						stmt.executeUpdate("CREATE INDEX IF NOT EXISTS
idx_person_name ON Person (name)");					}				}			}		}		catch (Exception ex)	
{			ex.printStackTrace();		}



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: (IF NOT EXISTS) in CREATE TABLE statement does not work

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

I guess you will have to search server node log for complete stack trace
with cause. Here we don't see what caused the exception.

Regards,
-- 
Ilya Kasnacheev


пн, 26 нояб. 2018 г. в 10:15, Qingping <15...@qq.com>:

> When testing Ignite 2.6.0 (2018-07-16), it was found that (IF NOT EXISTS)
> in the CREATE TABLE statement did not work. code show as below:
> Class.forName("org.apache.ignite.IgniteJdbcThinDriver"); try (Connection
> conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/")) {
> try (Statement stmt = conn.createStatement()) { stmt.executeUpdate("CREATE
> TABLE IF NOT EXISTS City(id LONG PRIMARY KEY," + " name VARCHAR) WITH
> \"template=replicated\""); } } After the first run is successful, an
> exception occurs again: Failed to execute SQL query [reqId=0,
> req=JdbcQueryExecuteRequest [schemaName=PUBLIC, pageSize=1024, maxRows=0,
> sqlQry=CREATE TABLE IF NOT EXISTS City(id LONG PRIMARY KEY, name VARCHAR)
> WITH "template=replicated", args=[], stmtType=UPDATE_STMT_TYPE]] at
> org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor.convert(DdlStatementsProcessor.java:582)
> at
> org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor.runDdlStatement(DdlStatementsProcessor.java:511)
> at
> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.doRunPrepared(IgniteH2Indexing.java:1736)
> at
> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.querySqlFields(IgniteH2Indexing.java:1671)
> at
> org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:2035)
> at
> org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:2030)
> at
> org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
> at
> org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2578)
> at
> org.apache.ignite.internal.processors.query.GridQueryProcessor.querySqlFields(GridQueryProcessor.java:2044)
> at
> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.executeQuery(JdbcRequestHandler.java:456)
> at
> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:203)
> at
> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:160)
> at
> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:44)
> at
> org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
> at
> org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
> at
> org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
> at
> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
> at
> org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at
> java.lang.Thread.run(Unknown Source)
> ------------------------------
> Sent from the Apache Ignite Users mailing list archive
> <http://apache-ignite-users.70518.x6.nabble.com/> at Nabble.com.
>