Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set daemon thread to fix jvm not exit (#2698) #2699

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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