Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Replaced ACK_FAILURE with RESET #511

Merged
merged 7 commits into from
Jul 24, 2018

Conversation

technige
Copy link
Contributor

@technige technige commented Jul 2, 2018

No description provided.

Copy link
Contributor

@zhenlineo zhenlineo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is really happy to see muteAckFailure removed!
I got one question after reading this PR.
Finally you might notice that your formatting is a bit different from the existing code.

messageDispatcher.unMuteAckFailure();
resetCompleted( completionFuture, success );
messageDispatcher.clearCurrentError();
if (completionFuture != null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this null check is added? Did we changed as old behaviour here?
Why this future could be null and is it safe to not have an else here?

Copy link
Contributor

@lutovich lutovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nigelsmall review completed. Made two comments. It would also be nice to add a test that asserts valid errors are thrown in an explicit transaction after a failed run. Smth like this for blocking and async API:

Transaction tx = session.beginTransaction();
        
tx.run( "RETURN invalid" ).consume(); // should throw syntax error
tx.run( "RETURN 1" ).consume(); // should throw some meaningful error
        
tx.close();

@@ -1157,7 +1157,7 @@ public void shouldFailToCommitWhenRunFailureIsConsumed()
}
catch ( ClientException e )
{
assertThat( e.getMessage(), startsWith( "Transaction rolled back" ) );
assertThat( e.getMessage(), startsWith( "No current transaction to commit." ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message change is quite weird. It exposes an implementation detail that driver resets a connection after an error. Do you think it is okay?

// try to write ACK_FAILURE before notifying the next response handler
ackFailureIfNeeded();
// write a RESET to "acknowledge" the failure
queue( new ResetResponseHandler( this, null ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to create a constructor that only takes an InboundMessageDispatcher and uses null inside ResetResponseHandler. Just to not pass null explicitly as the second parameter.

@lutovich lutovich force-pushed the 1.7-ack-failure-to-reset branch from 381ba5f to 63140b4 Compare July 24, 2018 12:38
technige and others added 7 commits July 24, 2018 16:31
Every failure is now "acknowledged" by sending a RESET message. It
makes database cleanup the state of the transaction and forget about
it. Thus every failure is fatal and transaction can't execute more
queries or commit.

This commit makes every failure treated as fatal for transactions.
Results of all queries need to be consumed before transaction is
committed or rolled back. This is done by `ResultCursorsHolder`
which keeps all cursors and queries them for errors. Previously,
it only waited for the first failure to arrive and there might've
been some more queries receiving results.

This commit fixes the problem by making the `ResultCursorsHolder`
properly await for all result cursors to be consumed. It does not do
blocking await but structures the result future to only be completed
when all results have arrived.
@lutovich lutovich force-pushed the 1.7-ack-failure-to-reset branch from 63e6b5f to 6707e7a Compare July 24, 2018 15:25
@lutovich lutovich merged commit f918eb2 into neo4j:1.7 Jul 24, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants