cherry pick #207 to release-3.1 (#210)

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

Co-authored-by: Wallace <bupt2013211450@gmail.com>
Co-authored-by: birdstorm <samuelwyf@hotmail.com>
This commit is contained in:
ti-srebot 2021-06-23 21:53:42 +08:00 committed by GitHub
parent c7d9ff151b
commit 05f1559eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -197,7 +197,7 @@ public class TiSession implements AutoCloseable {
return res;
}
public synchronized RegionManager getRegionManager() {
public RegionManager getRegionManager() {
RegionManager res = regionManager;
if (res == null) {
synchronized (this) {
@ -474,7 +474,9 @@ public class TiSession implements AutoCloseable {
synchronized (sessionCachedMap) {
sessionCachedMap.remove(conf.getPdAddrsString());
}
if (regionManager != null) {
regionManager.close();
}
if (tableScanThreadPool != null) {
tableScanThreadPool.shutdownNow();
}

View File

@ -99,6 +99,12 @@ public class RegionManager {
this.executor = null;
}
public synchronized void close() {
if (this.executor != null) {
this.executor.shutdownNow();
}
}
public Function<CacheInvalidateEvent, Void> getCacheInvalidateCallback() {
return cacheInvalidateCallback;
}