Neo4j Aura manages the health and maintenance of your AuraDB Instance cluster behind the scenes. In most instances, the specifics of the cluster are not needed for your application to make use of it. However, there is an edge case when your application may need to retry a transaction due to the current leader of the cluster becoming unavailable.
It is possible for a transaction to be interrupted by either the constituent parts of the AuraDB Instance temporarily losing their connections to one another or for the network connection between your application and the cluster to be lost prior to committing. If either of those scenarios were to happen, the driver would report an error similar to the following:
Caused by: org.neo4j.driver.v1.exceptions.ServiceUnavailableException: Connection
to the database terminated. This can happen due to network instabilities, or due
to restarts of the database.
For this reason, Neo4j Aura supports using transaction functions to retry transactions. An example from our documentation of a transaction function using Java is:
public void addPerson( final String name )
{
try ( Session session = driver.session() )
{
session.writeTransaction( new TransactionWork<Integer>()
{
@Override
public Integer execute( Transaction tx )
{
return createPersonNode( tx, name );
}
} );
}
}
private static int createPersonNode( Transaction tx, String name )
{
tx.run( "CREATE (a:Person {name: $name})", parameters( "name", name ) );
return 1;
}
Transaction functions can be used to handle any transient connection problems that occur between your application and your AuraDB Instance. Retries for any transaction functions are configured when constructing the Driver object in your application.
Should your application continue to receive errors even after performing a reasonable number of retries, please create a support ticket for assistance.
Comments
0 comments
Please sign in to leave a comment.