0
I have Spring-boot application which updates Neo4J database using several threads created by ExecutorService. Because of multithreading, I have locks sometimes which are not problem by theirselves. But each lock generates TransientException
and when I handle this exception and the thread receives new data to process, any subsequent write operation produces org.neo4j.driver.v1.exceptions.ClientException which says what Cannot run more statements in this transaction because it's already commited . Spring transaction is definitely new so it looks like Neo4J JDBC driver broke connection associated with the thread. And calling transactionManager.getTransaction(trxDefinition)
doesn't start Neo4J transaction actually. How is it possible to handle this? Version of neo4j-jdbc-bolt is 3.4.0
, piece of my code is below:
public Node convert(TraversalHandler<ConvertTraversalAttributes> converter, ConvertTraversalAttributes attributes) {
DefaultTransactionDefinition trxDefinition = new DefaultTransactionDefinition();
trxDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
final TransactionStatus transaction = transactionManager.getTransaction(trxDefinition);
try {
final Node node = converter.handle(attributes);
transactionManager.commit(transaction);
return node;
} catch (Exception e) {
LOGGER.error("Error converting node: ", e);
try {
transactionManager.rollback(transaction);
} catch (Exception rollbackException) {
// do nothing - transaction is already rolled back for some Neo4J (transient) exceptions
}
if (ExceptionUtils.isRetryableException(e)) {
throw new RetryableException(attributes.getChildNode());
} else {
throw e;
}
}
}
Even transactionManager.rollback(transaction);
fails for such error with the Already commited message what don't happen for all the other errors.