diff --git a/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/Workload.java b/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/Workload.java index 4b0f6f69e7da..9b12ed6e6b8f 100644 --- a/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/Workload.java +++ b/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/Workload.java @@ -55,19 +55,48 @@ protected void doWork() tx.success(); } ); } - catch ( InterruptedException e ) + catch ( Throwable e ) { - // whatever let's go on with the workload - Thread.interrupted(); + if ( isInterrupted( e ) || isTransient( e ) ) + { + // whatever let's go on with the workload + return; + } + + throw new RuntimeException( e ); } - catch ( TimeoutException | DatabaseShutdownException | TransactionFailureException e ) + } + + private boolean isTransient( Throwable e ) + { + if ( e == null ) { - // whatever let's go on with the workload + return false; } - catch ( Throwable e ) + + if ( e instanceof TimeoutException || e instanceof DatabaseShutdownException || + e instanceof TransactionFailureException ) { - throw new RuntimeException( e ); + return true; } + + return isInterrupted( e.getCause() ); + } + + private boolean isInterrupted( Throwable e ) + { + if ( e == null ) + { + return false; + } + + if ( e instanceof InterruptedException ) + { + Thread.interrupted(); + return true; + } + + return isInterrupted( e.getCause() ); } static void setupIndexes( Cluster cluster )