apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.29k stars 8.78k forks source link

springboot start deadlock with seata and shareding-jdbc #3647

Open xwang2023 opened 3 years ago

xwang2023 commented 3 years ago

Ⅰ. Issue Description

mysql databases has table over 500; the springboot starting in create sharding-jdbc's datasource enter into deadlock; because sharding-jdbc query database's table metadata for too long time, the seata create RMclient which start thread in delay 60s,

timerExecutor.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                clientChannelManager.reconnect(getTransactionServiceGroup());
            }
        }, SCHEDULE_DELAY_MILLS, SCHEDULE_INTERVAL_MILLS, TimeUnit.MILLISECONDS);

the thread get bean into spring container ,waiting lock in singleObject, but the springboot start-main-thread hold this lock

I have to update source code,update SCHEDULE_DELAY_MILLS from 60s to 180s,and start success io.seata.core.rpc.netty.AbstractNettyRemotingClient.class private static final long SCHEDULE_DELAY_MILLS = 60 * 1000L;

how easier config SCHEDULE_DELAY_MILLS ,do not modify source code?

stack log: Found one Java-level deadlock:

"timeoutChecker_2_1": waiting to lock monitor 0x0000023ff219ab08 (object 0x00000007910e81a8, a java.lang.Class), which is held by "timeoutChecker_1_1" "timeoutChecker_1_1": waiting to lock monitor 0x0000023fedde9908 (object 0x00000006cac04dd8, a java.util.concurrent.ConcurrentHashMap), which is held by "main" "main": waiting to lock monitor 0x0000023ff219ab08 (object 0x00000007910e81a8, a java.lang.Class), which is held by "timeoutChecker_1_1"

Java stack information for the threads listed above:

"timeoutChecker_2_1": at io.seata.discovery.registry.RegistryFactory.getInstance(RegistryFactory.java:42)

Found 1 deadlock.

xwang2023 commented 3 years ago

seata 1.4

wanqiu410 commented 2 years ago

是不是加了动态数据源,且把分表数据源加入到多数据源管理里,是的话,是的话,有可能是加入到多数据源时候,使用了@Lazy注解导致的,去掉这个注解应该就好了