Spring Boot mongo java app获取从池中检索项目的许可时中断

ufj5ltwl  于 2023-04-06  发布在  Spring
关注(0)|答案(2)|浏览(137)

任何人看到这个错误请咨询,不时我得到这个和数据不写入集合:(mongodb 4.0,mongodb java driver 4.1)

org.springframework.data.mongodb.UncategorizedMongoDbException: Interrupted acquiring a permit to retrieve an item from the pool ; nested exception is com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool
    at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:133) ~[spring-data-mongodb-3.1.3.jar!/:3.1.3]
    at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2882) ~[spring-data-mongodb-3.1.3.jar!/:3.1.3]
    at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:564) ~[spring-data-mongodb-3.1.3.jar!/:3.1.3]
    at org.springframework.data.mongodb.core.MongoTemplate.insertDocument(MongoTemplate.java:1444) ~[spring-data-mongodb-3.1.3.jar!/:3.1.3]
    at org.springframework.data.mongodb.core.MongoTemplate.doInsert(MongoTemplate.java:1244) ~[spring-data-mongodb-3.1.3.jar!/:3.1.3]
    at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:1176) ~[spring-data-mongodb-3.1.3.jar!/:3.1.3]
    at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.save(SimpleMongoRepository.java:85) ~[spring-data-mongodb-3.1.3.jar!/:3.1.3]
    at jdk.internal.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:289) ~[spring-data-commons-2.4.3.jar!/:2.4.3]
    at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137) ~[spring-data-commons-2.4.3.jar!/:2.4.3]
    at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121) ~[spring-data-commons-2.4.3.jar!/:2.4.3]
    at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:524) ~[spring-data-commons-2.4.3.jar!/:2.4.3]
    at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:285) ~[spring-data-commons-2.4.3.jar!/:2.4.3]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:531) ~[spring-data-commons-2.4.3.jar!/:2.4.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.3.jar!/:5.3.3]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:156) ~[spring-data-commons-2.4.3.jar!/:2.4.3]
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:131) ~[spring-data-commons-2.4.3.jar!/:2.4.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.3.jar!/:5.3.3]
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.4.3.jar!/:2.4.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.3.jar!/:5.3.3]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.3.jar!/:5.3.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.3.jar!/:5.3.3]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) ~[spring-aop-5.3.3.jar!/:5.3.3]
    at com.sun.proxy.$Proxy131.save(Unknown Source) ~[na:na]
    at org.epo.legacyservice.service.mongoDb.impl.HandleStatusFormServiceImpl.saveExecutedFormsStatus(HandleStatusFormServiceImpl.java:29) ~[classes!/:0.0.1-7529a486]
    at org.epo.legacyservice.service.impl.ExecutorFormServiceImpl.lambda$executeFromFile$5(ExecutorFormServiceImpl.java:148) ~[classes!/:0.0.1-7529a486]
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) ~[na:na]
    at org.epo.legacyservice.service.impl.ExecutorFormServiceImpl.lambda$executeFromFile$6(ExecutorFormServiceImpl.java:142) ~[classes!/:0.0.1-7529a486]
    at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:184) ~[reactor-core-3.4.2.jar!/:3.4.2]
    at reactor.core.publisher.FluxFilter$FilterSubscriber.tryOnNext(FluxFilter.java:142) ~[reactor-core-3.4.2.jar!/:3.4.2]
    at reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.runAsync(FluxPublishOn.java:992) ~[reactor-core-3.4.2.jar!/:3.4.2]
    at reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.run(FluxPublishOn.java:1067) ~[reactor-core-3.4.2.jar!/:3.4.2]
    at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84) ~[reactor-core-3.4.2.jar!/:3.4.2]
    at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37) ~[reactor-core-3.4.2.jar!/:3.4.2]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
    at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
 Caused by: com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool
    at com.mongodb.internal.connection.ConcurrentPool.acquirePermit(ConcurrentPool.java:203) ~[mongodb-driver-core-4.1.1.jar!/:na]
    at com.mongodb.internal.connection.ConcurrentPool.get(ConcurrentPool.java:140) ~[mongodb-driver-core-4.1.1.jar!/:na]
    at com.mongodb.internal.connection.ConcurrentPool.get(ConcurrentPool.java:123) ~[mongodb-driver-core-4.1.1.jar!/:na]
    at com.mongodb.internal.session.ServerSessionPool.get(ServerSessionPool.java:80) ~[mongodb-driver-core-4.1.1.jar!/:na]
    at com.mongodb.internal.session.BaseClientSessionImpl.<init>(BaseClientSessionImpl.java:44) ~[mongodb-driver-core-4.1.1.jar!/:na]
    at com.mongodb.client.internal.ClientSessionImpl.<init>(ClientSessionImpl.java:56) ~[mongodb-driver-sync-4.1.1.jar!/:na]
    at com.mongodb.client.internal.MongoClientDelegate.createClientSession(MongoClientDelegate.java:110) ~[mongodb-driver-sync-4.1.1.jar!/:na]
    at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.getClientSession(MongoClientDelegate.java:266) ~[mongodb-driver-sync-4.1.1.jar!/:na]
    at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:190) ~[mongodb-driver-sync-4.1.1.jar!/:na]
    at com.mongodb.client.internal.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:1009) ~[mongodb-driver-sync-4.1.1.jar!/:na]
    at com.mongodb.client.internal.MongoCollectionImpl.executeInsertOne(MongoCollectionImpl.java:470) ~[mongodb-driver-sync-4.1.1.jar!/:na]
    at com.mongodb.client.internal.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:453) ~[mongodb-driver-sync-4.1.1.jar!/:na]
    at com.mongodb.client.internal.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:447) ~[mongodb-driver-sync-4.1.1.jar!/:na]
    at org.springframework.data.mongodb.core.MongoTemplate.lambda$insertDocument$16(MongoTemplate.java:1450) ~[spring-data-mongodb-3.1.3.jar!/:3.1.3]
    at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:562) ~[spring-data-mongodb-3.1.3.jar!/:3.1.3]
    ... 38 common frames omitted
     Caused by: java.lang.InterruptedException: null
    at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1343) ~[na:na]
    at java.base/java.util.concurrent.Semaphore.acquire(Semaphore.java:318) ~[na:na]
    at com.mongodb.internal.connection.ConcurrentPool.acquirePermit(ConcurrentPool.java:199) ~[mongodb-driver-core-4.1.1.jar!/:na]
    ... 52 common frames omitted
osh3o9ms

osh3o9ms1#

它看起来像其他名为MongoClient.close()的线程

fiei3ece

fiei3ece2#

当我试图在MongoDB上执行一些操作时,我遇到了同样的问题。
我已经创建了连接池并设置了所需的属性。
我正在执行插入操作从一个线程创建使用执行器框架。
我还在线程中添加了睡眠,但是当线程中断时,对MongoDB的调用失败了。
所以我的观察是,如果它在一个线程中并且线程被中断,MongoDB连接调用就会失败。

相关问题