[ 
https://issues.apache.org/jira/browse/HBASE-25279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17231220#comment-17231220
 ] 

Viraj Jasani commented on HBASE-25279:
--------------------------------------

HMaster creates two ZKWatchers:

1. Inherited from HRegionServer for tracking master, primary watcher: which is 
closed properly once HRegionServer gets out of it's main loop i.e while 
(!isStopped() && isHealthy())

2. For client to locate meta in ZK: which doesn't seem to be closed
{code:java}
if (clientQuorumServers != null && !clientZkObserverMode) {
  // we need to take care of the ZK information synchronization
  // if given client ZK are not observer nodes
  ZKWatcher clientZkWatcher = new ZKWatcher(conf,
      getProcessName() + ":" + rpcServices.getSocketAddress().getPort() + 
"-clientZK", this,
      false, true);
  this.metaLocationSyncer = new MetaLocationSyncer(zooKeeper, clientZkWatcher, 
this);
  this.metaLocationSyncer.start();
  this.masterAddressSyncer = new MasterAddressSyncer(zooKeeper, 
clientZkWatcher, this);
  this.masterAddressSyncer.start();
  // set cluster id is a one-go effort
  ZKClusterId.setClusterId(clientZkWatcher, fileSystemManager.getClusterId());
}

{code}
We can try defining clientZkWatcher as final instance variable and close with 
shutdown() call soon after we delete clusterStateZNode?
{quote}In this case, these threads are tied to underlying ZK connections which 
must be cleaned up. So, I don't think thats the right solution.
{quote}
On one hand, making this thread as daemon doesn't seem harmful at all, but on 
the other hand, I agree that proper closures of ZKWatcher and thereby 
underlying RecoverableZookeeper seem more important.

[~elserj] If you are observing an improper cleanup of this ExecutorService 
(maybe as part of some unit tests), maybe we can take this opportunity to close 
all ZKWatchers in master and RS (if required) as part of this Jira to make sure 
we observe proper cleanup? WDYT?

> Non-daemon thread in ZKWatcher
> ------------------------------
>
>                 Key: HBASE-25279
>                 URL: https://issues.apache.org/jira/browse/HBASE-25279
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Josh Elser
>            Assignee: Josh Elser
>            Priority: Critical
>             Fix For: 3.0.0-alpha-1
>
>
> ZKWatcher spawns an ExecutorService which doesn't mark its threads as daemons 
> which will prevent clean shut downs.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to