'beginning implicit transaction' cannot be done... exception

47 views
Skip to first unread message

Matias Burak

unread,
Aug 4, 2016, 2:21:56 AM8/4/16
to Neo4j

Hi, anyone knows why I am getting this error?


'beginning implicit transaction' cannot be done when a session is in the 'IN_TRANSACTION' state.


This is using java-driver v1.0.4 and bolt 3.0.4


It looks that this is happening when the driver is doing a hasNext.

Is that starting an implicit transaction? 

I think it might have to do with concurrent bolt calls to do certain operations? It's weird....

Nigel Small

unread,
Aug 4, 2016, 5:49:42 PM8/4/16
to Neo4j, Alistair Jones
Hi Matias

It's hard to tell without seeing some code. What concurrency are you referring to?

I do think we need to fix that error though - it's very unhelpful to a typical application developer. Coincidentally, we're currently working on this part of the code so I'll make sure we improve the error message!

Nigel

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matias Burak

unread,
Aug 26, 2016, 4:57:16 PM8/26/16
to Neo4j, alistai...@neotechnology.com
Hi Nigel, I'm not sure but what I've seen is that there is a neo4j.Session thread that it's trying to do a 'begin' on a session worker that is already IN_TRANSACTION. 
How can I know who is doing that operation that is triggering that thread and why it's trying to begin an already started session worker?
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.

Matias Burak

unread,
Aug 26, 2016, 5:28:07 PM8/26/16
to Neo4j, alistai...@neotechnology.com
To add some code, I'm seeing a couple of places in the driver that fails trying to begin an already in transaction session.

if ( state == State.MARKED_SUCCESS )
{
conn.run( "COMMIT", Collections.<String, Value>emptyMap(), StreamCollector.NO_OP );
conn.discardAll();
conn.sync();
state = State.SUCCEEDED;
}
 
In the code above, on conn.sync() is failing and I see that in the neo4j thread is trying to begin the session which is in IN_TRANSACTION state.
Same thing happens in the code below which is part of InternalStatementResult.java, when it executes connection.receiveOne():

private boolean tryFetchNext()
{
while ( recordBuffer.isEmpty() )
{
if ( done )
{
return false;
}
connection.receiveOne();
}

return true;
}

Hope this helps,
Matias.

贾陆华

unread,
Nov 5, 2016, 4:30:05 AM11/5/16
to Neo4j
I also meet this bug,my exception stack at below:
java.sql.SQLException: Neo.ClientError.Statement.SyntaxError: Invalid input '。': expected whitespace or a property key name (line 1, column 48 (offset: 47))
"CREATE(n:TEST{Name:'TEST'}) SET n.p1 = 'A1', n.。p2 = 'A2';"
                                                ^
at org.neo4j.jdbc.bolt.BoltStatement.wrapException(BoltStatement.java:91)
at org.neo4j.jdbc.bolt.BoltStatement.executeUpdate(BoltStatement.java:103)
at org.neo4j.jdbc.bolt.BoltStatement.execute(BoltStatement.java:112)
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at com.emotibot.kgoff.mappers.UpdateNeo4jMapper.main(UpdateNeo4jMapper.java:242)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.neo4j.driver.v1.exceptions.ClientException: Invalid input '。': expected whitespace or a property key name (line 1, column 48 (offset: 47))
"CREATE(n:TEST{Name:'TEST'}) SET n.p1 = 'A1', n.。p2 = 'A2';"
                                                ^
at org.neo4j.driver.internal.connector.socket.SocketResponseHandler.handleFailureMessage(SocketResponseHandler.java:68)
at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.unpackFailureMessage(PackStreamMessageFormatV1.java:464)
at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.read(PackStreamMessageFormatV1.java:425)
at org.neo4j.driver.internal.connector.socket.SocketClient.receiveOne(SocketClient.java:130)
at org.neo4j.driver.internal.connector.socket.SocketClient.receiveAll(SocketClient.java:124)
at org.neo4j.driver.internal.connector.socket.SocketConnection.receiveAll(SocketConnection.java:129)
at org.neo4j.driver.internal.connector.socket.SocketConnection.sync(SocketConnection.java:108)
at org.neo4j.driver.internal.connector.ConcurrencyGuardingConnection.sync(ConcurrencyGuardingConnection.java:136)
at org.neo4j.driver.internal.pool.PooledConnection.sync(PooledConnection.java:157)
at org.neo4j.driver.internal.InternalTransaction.close(InternalTransaction.java:110)
at org.neo4j.jdbc.bolt.BoltStatement.executeInternal(BoltStatement.java:68)
at org.neo4j.jdbc.bolt.BoltStatement.executeUpdate(BoltStatement.java:96)
... 9 more


java.sql.SQLException: Neo.ClientError.Request.Invalid: 'beginning implicit transaction' cannot be done when a session is in the 'IN_TRANSACTION' state.
at org.neo4j.jdbc.bolt.BoltStatement.wrapException(BoltStatement.java:91)
at org.neo4j.jdbc.bolt.BoltStatement.executeUpdate(BoltStatement.java:103)
at org.neo4j.jdbc.bolt.BoltStatement.execute(BoltStatement.java:112)
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at com.emotibot.kgoff.mappers.UpdateNeo4jMapper.main(UpdateNeo4jMapper.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.neo4j.driver.v1.exceptions.ClientException: 'beginning implicit transaction' cannot be done when a session is in the 'IN_TRANSACTION' state.
at org.neo4j.driver.internal.connector.socket.SocketResponseHandler.handleFailureMessage(SocketResponseHandler.java:68)
at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.unpackFailureMessage(PackStreamMessageFormatV1.java:464)
at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Reader.read(PackStreamMessageFormatV1.java:425)
at org.neo4j.driver.internal.connector.socket.SocketClient.receiveOne(SocketClient.java:130)
at org.neo4j.driver.internal.connector.socket.SocketClient.receiveAll(SocketClient.java:124)
at org.neo4j.driver.internal.connector.socket.SocketConnection.receiveAll(SocketConnection.java:129)
at org.neo4j.driver.internal.connector.socket.SocketConnection.sync(SocketConnection.java:108)
at org.neo4j.driver.internal.connector.ConcurrencyGuardingConnection.sync(ConcurrencyGuardingConnection.java:136)
at org.neo4j.driver.internal.pool.PooledConnection.sync(PooledConnection.java:157)
at org.neo4j.driver.internal.InternalTransaction.close(InternalTransaction.java:110)
at org.neo4j.jdbc.bolt.BoltStatement.executeInternal(BoltStatement.java:68)
at org.neo4j.jdbc.bolt.BoltStatement.executeUpdate(BoltStatement.java:96)
... 9 more

my test code is:
1. The first cypher, I add a '。' for p2 property deliberately.
2. The second cypher i delete the '。' character, i want reuse this connection, but i got a exception too.
3. I debug this exception, found that this error is neo4j server response.
4. I use neo4j jdbc 3.0.1.

Connection conn = null;
try {
conn = ds.getConnection();

boolean ret = conn.createStatement().execute("CREATE(n:TEST{Name:'TEST'}) SET n.p1 = 'A1', n.。p2 = 'A2';");
System.out.println("execute ret:" + ret);
} catch (SQLException e) {
e.printStackTrace();

try {
if (conn != null) {
boolean ret = conn.createStatement().execute("CREATE(n:TEST{Name:'TEST'}) SET n.p1 = 'A1', n.p2 = 'A2';");
System.out.println("retry execute ret:" + ret);
}
} catch (SQLException e1) {
e1.printStackTrace();
}
}


在 2016年8月4日星期四 UTC+8下午2:21:56,Matias Burak写道:

Luhua Jia

unread,
Nov 5, 2016, 4:45:46 AM11/5/16
to Neo4j
@Nigel Small can you help me?
Reply all
Reply to author
Forward
0 new messages