首页 > 数据库 >postgresql 的 idle_session_timeout 与连接池的 max-ide-time参数

postgresql 的 idle_session_timeout 与连接池的 max-ide-time参数

时间:2023-06-01 11:22:08浏览次数:68  
标签:core postgresql reactor 16 max jar 3.4 idle java

看下面的异常:

  • 下面的错误说:terminating connection due to idle-session timeout

  • 下面的这个错误说:Caused by: reactor.pool.PoolShutdownException: Pool has been shut down

reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection; nested exception is reactor.pool.PoolShutdownException: Pool has been shut down
Caused by: org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection; nested exception is reactor.pool.PoolShutdownException: Pool has been shut down
    at org.springframework.r2dbc.connection.ConnectionFactoryUtils.lambda$getConnection$0(ConnectionFactoryUtils.java:88) ~[spring-r2dbc-5.3.17.jar:5.3.17]
    at reactor.core.publisher.Mono.lambda$onErrorMap$31(Mono.java:3733) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:106) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxRetry$RetrySubscriber.onError(FluxRetry.java:95) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.pool.AbstractPool$Borrower.fail(AbstractPool.java:477) ~[reactor-pool-0.2.8.jar:0.2.8]
    at reactor.pool.SimpleDequePool.doAcquire(SimpleDequePool.java:292) ~[reactor-pool-0.2.8.jar:0.2.8]
    at reactor.pool.AbstractPool$Borrower.request(AbstractPool.java:432) ~[reactor-pool-0.2.8.jar:0.2.8]
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:110) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.pool.SimpleDequePool$QueueBorrowerMono.subscribe(SimpleDequePool.java:720) ~[reactor-pool-0.2.8.jar:0.2.8]
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxRetry$RetrySubscriber.resubscribe(FluxRetry.java:117) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.MonoRetry.subscribeOrReturn(MonoRetry.java:50) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4385) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:132) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Operators.error(Operators.java:198) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.MonoError.subscribe(MonoError.java:53) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:55) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4400) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.MonoUsingWhen.subscribe(MonoUsingWhen.java:96) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4400) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onNext(MonoFlatMapMany.java:195) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onNext(FluxDefaultIfEmpty.java:101) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:127) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:127) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:210) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:127) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.MonoCollectList$MonoCollectListSubscriber.onComplete(MonoCollectList.java:128) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:368) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onComplete(FluxConcatMap.java:276) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Operators.complete(Operators.java:137) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:148) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:87) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Flux.subscribe(Flux.java:8469) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxUsingWhen.subscribe(FluxUsingWhen.java:94) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4400) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Mono.subscribeWith(Mono.java:4515) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4371) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4307) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4254) ~[reactor-core-3.4.16.jar:3.4.16]
    at com.fengyun.medical.orderservice.handlers.rabbitmq.rpc.OrderPaymentHandler.lambda$updatePayStatus$2(OrderPaymentHandler.java:66) ~[classes/:na]
    at reactor.core.publisher.LambdaSubscriber.onNext(LambdaSubscriber.java:160) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:793) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxCreate$BufferAsyncSink.next(FluxCreate.java:718) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.core.publisher.FluxCreate$SerializedFluxSink.next(FluxCreate.java:154) ~[reactor-core-3.4.16.jar:3.4.16]
    at reactor.rabbitmq.Receiver.lambda$null$9(Receiver.java:216) ~[reactor-rabbitmq-1.5.5.jar:1.5.5]
    at com.rabbitmq.client.impl.recovery.AutorecoveringChannel$2.handleDelivery(AutorecoveringChannel.java:588) ~[amqp-client-5.13.1.jar:5.13.1]
    at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:149) ~[amqp-client-5.13.1.jar:5.13.1]
    at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:104) ~[amqp-client-5.13.1.jar:5.13.1]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
    at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: reactor.pool.PoolShutdownException: Pool has been shut down
    ... 51 common frames omitted

造成上面的原因是 PG中的参数idle_session_timeout,这个参数默认为0,表示禁用。数据库默认的最大连接数为100.在频繁的数据库操作中会报最大连接数已满,当时为了解决这个问题我修改了配置文件中idle_session_timeout为5分钟,也由此为后来的报错埋下了坑。当使用连接池去连接时,连接池中的max-ide-time默认为30分钟。数据库在超过5分钟内没有交互时,会自动断开连接而连接池此时还不知道连接已断,所以就造成上面的错误。

解决方法:

修改连接池参数: max-ide-time 为10s



来自为知笔记(Wiz)

标签:core,postgresql,reactor,16,max,jar,3.4,idle,java
From: https://www.cnblogs.com/baiyifengyun/p/17448436.html

相关文章

  • MaxCompute 物化视图智能推荐最佳实践
    作者夏俊伟 阿里云高级产品专家 / 郑君正阿里云高级技术专家什么是物化视图MaxCompute物化视图是一种预先计算和存储结果数据的数据对象,也可以称之为“实体化视图”。物化视图可以作为一张虚拟表存在于MaxCompute项目中,它的内容是一个或多个表的聚合,过滤以及Join组合计算结......
  • java同步mysql的数据到PostgreSQL时报错ERROR: invalid byte sequence for encoding "
    最近,同事在做一个功能,通过java程序将mysql中的一张表的数据同步到pgsql中,在同步过程中,插入到pgsql中出现了如下错误:`###Errorupdatingdatabase.Cause:org.postgresql.util.PSQLException:ERROR:invalidbytesequenceforencoding"UTF8":0x00在位置:unnamedportalpa......
  • 关于mysql 创建索引报错 1071 specified key was too long ;max key length is 3027
    另一种张表也是相同的字段创建索引却能成功,在网上查了一些资料。后来发现是两张表字段都用的varchar类型,不过能成功建索引的表设置的长度是50,而不能成功的表里设置的255,修改字符长度就能成功建索引了。关于varchar(50)和varchar(255)的区别:https://dba.stackexchange.com/questio......
  • SQLite与MySQL与PostgreSQL:关系数据库的比较
    概述和功能SQLite是一个基于文件的嵌入式RDBMS,不需要任何安装或设置。反过来,这意味着应用程序不在需要启动,停止或配置的单独服务器进程下运行。这种无服务器架构使数据库能够跨平台兼容。完整的SQL数据库包含在单个磁盘文件中,所有读取和写入都直接在此磁盘文件上进行。由于数据直接......
  • PostgreSQL 9.6 文档: 数据类型
    章8.数据类型目录8.1. 数字类型8.1.1. 整数类型8.1.2. 任意精度数字8.1.3. 浮点类型8.1.4. 序数类型8.2. 货币类型8.3. 字符类型8.4. 二进制数据类型8.4.1. bytea的十六进制格式8.4.2. bytea的逃逸格式8.5. 日期/时间类型8.5.1. 日期/时间输入8.5.2. 日期/时间输......
  • leetcode 53. Maximum Subarray
    Givenanintegerarraynums,findthecontiguoussubarray (containingatleastonenumber)whichhasthelargestsumandreturnitssum.Example:Input:[-2,1,-3,4,-1,2,1,-5,4],Output:6Explanation: [4,-1,2,1]hasthelargestsum=6.Followup:Ifyouhavef......
  • 3.7 softmax回归的简洁实现
    1.导入包,加载Mnist数据集 2.代码:importtorchfromtorchimportnnfromd2limporttorchasd2lbatch_size=256train_iter,test_iter=d2l.load_data_fashion_mnist(batch_size)#PyTorch不会隐式地调整输入的形状。因此,#我们加入一个Flatten()层展平。Flatt......
  • postgresql9.2.24安装
    1、yum安装 yum install -y postgresql-server postgresql-contrib 2、初始化 postgresql-setup initdb 3、挂载数据盘 ln -s /data/pgsql /var/lib/pgsqlchown -R postgres:postgres pgsql 4、修改配置文件pg_hba.conf localall......
  • 数据库流转工具—Maxwell
    第1章Maxwell简介1.1Maxwell概述Maxwell是由美国Zendesk公司开源,用Java编写的MySQL变更数据抓取软件。它会实时监控Mysql数据库的数据变更操作(包括insert、update、delete),并将变更数据以JSON格式发送给Kafka、Kinesi等流数据处理平台。官网地址:http://maxwells-daemon.io/......
  • vcftools中 --max-missing 参数
     --max-missing参数表示:最大的丢失率不超过xxxx。(base)[root@PC1test]#lsoutcome.mapoutcome.pedoutcome.vcf(base)[root@PC1test]#catoutcome.map1snp10559101snp20852041snp301229481snp4......