fix not stop scheduler (#207)

* fix not stop scheduler

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* address comment

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
This commit is contained in:
Wallace 2021-06-23 15:00:47 +08:00 committed by GitHub
parent d29cf0079c
commit 550487db9c
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;
}