Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

Spring Data Neo4j: Unable to acquire connection from the pool within configured maximum time

I am doing stress testing of my Neo4j client which is built using spring-boot-starter-data-neo4j.

After sometime passed, application throwing error Unable to acquire connection for any request.

This is my bean configuration for Neo4j connection. can someone check and tell what can be done

id("org.springframework.boot") version "2.4.0"



@Configuration
    @EnableTransactionManagement
    class Neo4jConfig(
        @Value("${spring.neo4j.uri}")
        val neo4jDBUri: String,

        @Value("${spring.neo4j.authentication.username}")
        val neo4jDbUserName: String,

        @Value("${spring.neo4j.authentication.password}")
        val neo4jDbUserPassword: String
    ) : AbstractNeo4jConfig() {
//        https://medium.com/neo4j/try-and-then-retry-there-can-be-failure-30bf336383da
        @Bean
        override fun driver(): Driver {
            val config: Config = Config.builder()
                .withMaxTransactionRetryTime(60, TimeUnit.SECONDS)
                .withLeakedSessionsLogging()
                .withRoutingTablePurgeDelay(1, TimeUnit.SECONDS)
                .withConnectionAcquisitionTimeout(2 * 60, TimeUnit.SECONDS)
                .withConnectionLivenessCheckTimeout(2 * 60, TimeUnit.SECONDS)
                .withDriverMetrics()
                .withMaxConnectionPoolSize(100)
                .build()

            return GraphDatabase
                .driver(neo4jDBUri, AuthTokens.basic(neo4jDbUserName, neo4jDbUserPassword), config)
        }
    }

    // Refer: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.4.0-M2-Release-Notes#neo4j-1
    @Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME)
    fun reactiveTransactionManager(
        driver: Driver,
        databaseNameProvider: ReactiveDatabaseSelectionProvider
    ): ReactiveTransactionManager = ReactiveNeo4jTransactionManager(driver, databaseNameProvider)

    // Refer: https://hantsy.medium.com/data-auditing-with-spring-data-neo4j-11d6461146ff
    @Configuration(proxyBeanMethods = false)
    @EnableReactiveNeo4jAuditing
    internal class DataConfig {
        @Bean
        fun reactiveAuditorAware(): ReactiveAuditorAware<String> = ReactiveAuditorAware { Mono.just("Audit enabled") }
    }

Error message

webFilters.ControllerConfig in Neo4jDriverIO-2-2 - Returning HTTP 400 Bad Requestorg.springframework.dao.InvalidDataAccessResourceUsageException: Unable to acquire connection from the pool within configured maximum time of 120000ms; Error code 'N/A'   at org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator.translateImpl(Neo4jPersistenceExceptionTranslator.java:105)    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s):    |_ checkpoint ? Handler 

controller.UserApiController#createUser(UserReqModel, Continuation) [DispatcherHandler]Stack trace:     at org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator.translateImpl(Neo4jPersistenceExceptionTranslator.java:105)        at org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator.translateExceptionIfPossible(Neo4jPersistenceExceptionTranslator.java:91)      at org.springframework.data.neo4j.core.DefaultReactiveNeo4jClient.potentiallyConvertRuntimeException(DefaultReactiveNeo4jClient.java:271)       at org.springframework.data.neo4j.core.DefaultReactiveNeo4jClient.access$200(DefaultReactiveNeo4jClient.java:54)        at org.springframework.data.neo4j.core.DefaultReactiveNeo4jClient$DefaultRecordFetchSpec.la

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...