HBASE-11923 Potential race condition in RecoverableZookeeper.checkZk() (Lars Hofhansl)
This commit is contained in:
parent
aee7379b7e
commit
d8f8a58236
|
@ -75,7 +75,7 @@ import org.htrace.TraceScope;
|
|||
public class RecoverableZooKeeper {
|
||||
private static final Log LOG = LogFactory.getLog(RecoverableZooKeeper.class);
|
||||
// the actual ZooKeeper client instance
|
||||
volatile private ZooKeeper zk;
|
||||
private ZooKeeper zk;
|
||||
private final RetryCounterFactory retryCounterFactory;
|
||||
// An identifier of this process in the cluster
|
||||
private final String identifier;
|
||||
|
@ -134,7 +134,7 @@ public class RecoverableZooKeeper {
|
|||
* @return The created Zookeeper connection object
|
||||
* @throws KeeperException
|
||||
*/
|
||||
protected ZooKeeper checkZk() throws KeeperException {
|
||||
protected synchronized ZooKeeper checkZk() throws KeeperException {
|
||||
if (this.zk == null) {
|
||||
try {
|
||||
this.zk = new ZooKeeper(quorumServers, sessionTimeout, watcher);
|
||||
|
@ -146,7 +146,7 @@ public class RecoverableZooKeeper {
|
|||
return zk;
|
||||
}
|
||||
|
||||
public void reconnectAfterExpiration()
|
||||
public synchronized void reconnectAfterExpiration()
|
||||
throws IOException, KeeperException, InterruptedException {
|
||||
if (zk != null) {
|
||||
LOG.info("Closing dead ZooKeeper connection, session" +
|
||||
|
|
Loading…
Reference in New Issue