From 289c12dea3cf66500feb1b62f64c45b3838fdadc Mon Sep 17 00:00:00 2001 From: larsh Date: Tue, 15 Jan 2013 22:14:23 +0000 Subject: [PATCH] HBASE-7551 nodeChildrenChange event may happen after the transition to RS_ZK_REGION_SPLITTING in SplitTransaction causing the SPLIT event to be missed in the master side. (Ram, Ted, and Lars H) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1433696 13f79535-47bb-0310-9956-ffa450edef68 --- .../hbase/master/AssignmentManager.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java index 5d8d836e4b1..ca1f25eb399 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java @@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.master; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -40,7 +39,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import com.google.common.collect.LinkedHashMultimap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; @@ -85,6 +83,8 @@ import org.apache.zookeeper.KeeperException.NoNodeException; import org.apache.zookeeper.KeeperException.NodeExistsException; import org.apache.zookeeper.data.Stat; +import com.google.common.collect.LinkedHashMultimap; + /** * Manages and performs region assignment. *

@@ -1061,13 +1061,27 @@ public class AssignmentManager extends ZooKeeperListener { ZKUtil.listChildrenAndWatchForNewChildren( watcher, watcher.assignmentZNode); if (children != null) { + Stat stat = new Stat(); for (String child : children) { // if region is in transition, we already have a watch // on it, so no need to watch it again. So, as I know for now, // this is needed to watch splitting nodes only. if (!regionStates.isRegionInTransition(child)) { - ZKUtil.watchAndCheckExists(watcher, - ZKUtil.joinZNode(watcher.assignmentZNode, child)); + stat.setVersion(0); + byte[] data = ZKAssign.getDataAndWatch(watcher, + ZKUtil.joinZNode(watcher.assignmentZNode, child), stat); + if (data != null && stat.getVersion() > 0) { + try { + RegionTransition rt = RegionTransition.parseFrom(data); + + //See HBASE-7551, handle splitting too, in case we miss the node change event + if (rt.getEventType() == EventType.RS_ZK_REGION_SPLITTING) { + handleRegion(rt, stat.getVersion()); + } + } catch (DeserializationException de) { + LOG.error("error getting data for " + child, de); + } + } } } }