【达梦】偶现“网络通信异常”

发布时间 2023-04-04 18:49:58作者: aaacarrot

背景:

DRUID + mybatis + 达梦数据库

上线后,偶现 “网络通信异常” 的错误

解决方案

原因:不知道

但解决方案是在
application.yml 上的 druid 配置做了一下调整
一开始 druid 的配置是这样子的:

druid:
  url: jdbc:dm://10.12.xx.xx:5236/dev?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true
  username: xx
  password: xx
  useUnicode: true
  characterEncoding: UTF8
  useSSL: false
  maxWait: 10000
  maxActive: 36
  initialSize: 36
  minIdle: 36

加三个配置项:

  validationQuery: "select now"
  testWhileIdle: true
  testOnBorrow: false
  testOnReturn: false

成品:

druid:
  url: jdbc:dm://10.12.xx.xx:5236/dev?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true
  username: xx
  password: xx
  useUnicode: true
  characterEncoding: UTF8
  useSSL: false
  maxWait: 10000
  maxActive: 36
  initialSize: 36
  minIdle: 36
  validationQuery: "select now"
  testWhileIdle: true
  testOnBorrow: false
  testOnReturn: false

嗯。。。

然后,貌似就好了。玩不懂,如果再出现,可以考虑一下这方面的可能性吧。

再记录一下
P.S.

  maxActive: 36
  initialSize: 36
  minIdle: 36

这三个选项,调大了,好像报错频率还变高了。。。
(莫然地想起 GC回收频率,把内存调大,GC反而更频繁的一个案例)