Skip to content

Commit

Permalink
Set daemon thread to fix jvm not exit (#2698) (#2699)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored May 8, 2023
1 parent fcda956 commit 3429215
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.pingcap.tikv.TiSession
import com.pingcap.tikv.exception.TiInternalException
import com.pingcap.tikv.meta.TiTimestamp
import com.pingcap.tikv.util.{BackOffer, ConcreteBackOffer}
import com.google.common.util.concurrent.ThreadFactoryBuilder
import org.slf4j.LoggerFactory

import java.util.concurrent.{Executors, ScheduledExecutorService, TimeUnit}
Expand All @@ -34,7 +35,8 @@ case class ServiceSafePoint(

private final val logger = LoggerFactory.getLogger(getClass.getName)
private var minStartTs = Long.MaxValue
val service: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor()
val service: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setNameFormat("serviceSafePoint-thread-%d").setDaemon(true).build)
service.scheduleAtFixedRate(
() => {
if (minStartTs != Long.MaxValue) {
Expand Down
7 changes: 6 additions & 1 deletion tikv-client/src/main/java/com/pingcap/tikv/TiSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ public Map<String, Boolean> getStoreStatusCache() {
synchronized (this) {
if (storeStatusCache == null) {
storeStatusCache = new ConcurrentHashMap<>();
storeStatusCacheExecutor = Executors.newScheduledThreadPool(1);
storeStatusCacheExecutor =
Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder()
.setNameFormat("storeStatus-thread-%d")
.setDaemon(true)
.build());
storeStatusCacheExecutor.scheduleAtFixedRate(
() -> {
storeStatusCache.replaceAll(
Expand Down

0 comments on commit 3429215

Please sign in to comment.