最近发现在线上环境,多线程情况下通过OB的数据库驱动操作OB数据库前出现线程死锁的情况,并且两个线程都是执行到同一个方法时出现的死锁,初步怀疑并发情况下OB的JDBC连接存在线程不安全的情况,但是死锁的资源又只占用的是同一个ReentrantLock对象,这里让人不太理解。具体线程堆栈日志如下(只筛选了异常的线程日志):
线程死锁.txt (37.7 KB)
OB的SDK使用的是:
<dependency>
<groupId>com.oceanbase</groupId>
<artifactId>oceanbase-client</artifactId>
<version>2.2.7.2</version>
</dependency>
查看线上OB监控发现期间使用到的SQL语句均无慢SQL的情况:
我们项目使用的是Druid连接池,连接池的配置如下:
spring:
transaction:
rollback-on-commit-failure: true
datasource:
druid:
driver-class-name: com.alipay.oceanbase.jdbc.Driver
url: jdbc:oceanbase://ip:port?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=TRUE&allowMultiQueries=true&useLocalSessionState=TRUE&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&socketTimeout=3000000&connectTimeout=60000
username: xxx
password: xxx
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
max-open-prepared-statements: 100
max-active: 200
initial-size: 20
max-wait: 3000
min-idle: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
max-evictable-idle-time-millis: 600000
keep-alive: true
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
connection-init-sqls:
- SET SESSION ob_query_timeout = 600000000;
- SET SESSION ob_trx_timeout = 600000000;
请求OB的大佬协助看下该问题是不是我所描述的厂家数据库驱动的问题,还是其他问题,感谢!