[Bug] Because of thread-safety problem , replace connectionMap with concurrentMap from hashMap. (#4774)

Thread [Connect-Scheduler-Check-Timer] fail to iterate the connectionMap , because other threads will modify the connectionMap at the same time.
Fe's connection which is timed out can't be released because of thread [Connect-Scheduler-Check-Timer] not working.
This commit is contained in:
chovy
2020-10-22 11:15:21 +08:00
committed by GitHub
parent 7b2762b1b1
commit 0c37b42bc7

View File

@ -46,7 +46,7 @@ public class ConnectScheduler {
private int maxConnections;
private int numberConnection;
private AtomicInteger nextConnectionId;
private Map<Long, ConnectContext> connectionMap = Maps.newHashMap();
private Map<Long, ConnectContext> connectionMap = Maps.newConcurrentMap();
private Map<String, AtomicInteger> connByUser = Maps.newHashMap();
private ExecutorService executor = ThreadPoolManager.newDaemonCacheThreadPool(Config.max_connection_scheduler_threads_num, "connect-scheduler-pool", true);