Spring + Neo4J, TransientException broke connection for the thread

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.

I cannot make sense from the classes I am seeing and what you are describing.
Neo4j-OGM is not equals and does not use Neo4j-JDBC. It can use Bolt or HTTP.

Also, if this is Springs PlatformTransactionManager, your are using it wrong. It is usually not meant to be used directly like this, but either through the TransactionTemplate or @Transactional.

Last but not least: Are running this inside Neo4j as stored procedure? That is at least my assumption when I read "Traversal"…

Sorry, but we need a bit more information (dependencies, usage etc.) /cc @florent_biville

Duplicate of multithreading - Spring + Neo4J, TransientException brokes connection for the thread - Stack Overflow, answering in SO.

Yes, I copied the question here, thanks.

We use Neo4J JDBC.
Regarding to the direct usage of PlatformTransationManager, it's just consequences of my experiments. It's not Neo4J stored procedure, it's pure Spring Boot app, Spring Boot version is 2.2.4.