Commit 16536b4a authored by RagnarW's avatar RagnarW Committed by Ragnar Wernersson
Browse files

ReplicationError is considered transient in tests

A lot of stress tests are failing because these statuses are not
considered transient. This should solve that issue.
parent 4312c9f6
Showing with 12 additions and 6 deletions
+12 -6
......@@ -60,6 +60,7 @@ import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.TransactionFailureException;
import org.neo4j.graphdb.security.WriteOperationsNotAllowedException;
import org.neo4j.helpers.AdvertisedSocketAddress;
import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.kernel.internal.DatabaseHealth;
import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.kernel.monitoring.Monitors;
......@@ -511,29 +512,34 @@ public class Cluster
return awaitEx( supplier, notNull()::test, timeout, timeUnit );
}
private boolean isTransientFailure( Throwable e )
private static boolean isTransientFailure( Throwable e )
{
// TODO: This should really catch all cases of transient failures. Must be able to express that in a clearer
// manner...
return (e instanceof IdGenerationException) || isLockExpired( e ) || isLockOnFollower( e ) ||
isWriteNotOnLeader( e );
return (e instanceof IdGenerationException) || isLockExpired( e ) || isLockOnFollower( e ) || isWriteNotOnLeader( e ) || isUnableToReplicate( e );
}
private boolean isWriteNotOnLeader( Throwable e )
private static boolean isWriteNotOnLeader( Throwable e )
{
return e instanceof WriteOperationsNotAllowedException &&
e.getMessage().startsWith( String.format( LeaderCanWrite.NOT_LEADER_ERROR_MSG, "" ) );
}
private boolean isLockOnFollower( Throwable e )
private static boolean isLockOnFollower( Throwable e )
{
return e instanceof AcquireLockTimeoutException &&
(e.getMessage().equals( LeaderOnlyLockManager.LOCK_NOT_ON_LEADER_ERROR_MESSAGE ) ||
e.getCause() instanceof NoLeaderFoundException);
}
private boolean isLockExpired( Throwable e )
private static boolean isUnableToReplicate( Throwable e )
{
return e instanceof org.neo4j.internal.kernel.api.exceptions.TransactionFailureException &&
((org.neo4j.internal.kernel.api.exceptions.TransactionFailureException) e).status().equals( Status.Cluster.ReplicationFailure );
}
private static boolean isLockExpired( Throwable e )
{
return e instanceof TransactionFailureException &&
e.getCause() instanceof org.neo4j.internal.kernel.api.exceptions.TransactionFailureException &&
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment