Skip to content

Commit 1d734a4

Browse files
author
Zhen
committed
Fix the problem where the tx cannot run after ack_failure
The reason of the test failure was that the roll_back is not sent to the server to terminate current tx. So the next run will just inject into previous tx.
1 parent fccaaa7 commit 1d734a4

File tree

3 files changed

+4
-26
lines changed

3 files changed

+4
-26
lines changed

driver/src/main/java/org/neo4j/driver/internal/InternalSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void run()
148148
//must check if transaction has been closed
149149
if (currentTransaction != null)
150150
{
151-
currentTransaction.markAsRolledBack();
151+
currentTransaction.failure();
152152
currentTransaction = null;
153153
connection.onError( null );
154154
}

driver/src/main/java/org/neo4j/driver/internal/InternalTransaction.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ public void close()
112112
}
113113
else if ( state == State.MARKED_FAILED || state == State.ACTIVE )
114114
{
115-
// If alwaysValid of the things we've put in the queue have been sent off, there is no need to
116-
// do this, we could just clear the queue. Future optimization.
117115
conn.run( "ROLLBACK", Collections.<String, Value>emptyMap(), StreamCollector.NO_OP );
118116
conn.discardAll();
119117
conn.sync();
@@ -171,6 +169,8 @@ public StatementResult run( Statement statement )
171169
}
172170
catch ( Neo4jException e )
173171
{
172+
// Failed to send messages to the server probably due to IOException in the socket.
173+
// So we should stop sending more messages in this transaction
174174
state = State.FAILED;
175175
throw e;
176176
}
@@ -200,12 +200,5 @@ public TypeSystem typeSystem()
200200
return InternalTypeSystem.TYPE_SYSTEM;
201201
}
202202

203-
// TODO: This is wrong. This is only needed because we changed the SSM
204-
// to move to IDLE on any exception (so the normal `ROLLBACK` statement won't work).
205-
// We should change the SSM to move to some special ROLLBACK_ONLY state instead and
206-
// remove this code path
207-
public void markAsRolledBack()
208-
{
209-
state = State.ROLLED_BACK;
210-
}
203+
211204
}

driver/src/test/java/org/neo4j/driver/v1/integration/ResultStreamIT.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import org.neo4j.driver.v1.Record;
2525
import org.neo4j.driver.v1.StatementResult;
26-
import org.neo4j.driver.v1.types.Node;
2726
import org.neo4j.driver.v1.util.TestNeo4jSession;
2827

2928
import static org.junit.Assert.assertEquals;
@@ -62,20 +61,6 @@ public void shouldHaveFieldNamesInResult()
6261
assertEquals( "[n]", res.keys().toString() );
6362
}
6463

65-
@Test
66-
public void should()
67-
{
68-
// When
69-
StatementResult res = session.run( "CREATE (n:TestNode {name:'test', prop: [42]}) RETURN n" );
70-
71-
Node n = res.next().get( "n" ).asNode();
72-
System.out.println( n );
73-
// Then
74-
assertEquals( "[n]", res.keys().toString() );
75-
assertNotNull( res.single() );
76-
assertEquals( "[n]", res.keys().toString() );
77-
}
78-
7964
@Test
8065
public void shouldGiveHelpfulFailureMessageWhenAccessNonExistingField() throws Throwable
8166
{

0 commit comments

Comments
 (0)