HBASE-4124 ZK restarted while a region is being assigned, new active HM re-assigns it but the RS warns 'already online on this server'

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1162919 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-08-29 17:51:44 +00:00
parent 53e7f73ab9
commit cbb6aac2a7
2 changed files with 24 additions and 6 deletions

View File

@ -496,6 +496,9 @@ Release 0.90.5 - Unreleased
HBASE-4253 TestScannerTimeOut.test3686a and TestHTablePool. HBASE-4253 TestScannerTimeOut.test3686a and TestHTablePool.
testReturnDifferentTable() failure because of using new testReturnDifferentTable() failure because of using new
HTable(tablename) (ramkrishna.s.vasudevan) HTable(tablename) (ramkrishna.s.vasudevan)
HBASE-4124 ZK restarted while a region is being assigned, new active HM
re-assigns it but the RS warns 'already online on this server'
(Gaojinchao)
IMPROVEMENT IMPROVEMENT
HBASE-4205 Enhance HTable javadoc (Eric Charles) HBASE-4205 Enhance HTable javadoc (Eric Charles)

View File

@ -369,8 +369,11 @@ public class AssignmentManager extends ZooKeeperListener {
synchronized (regionsInTransition) { synchronized (regionsInTransition) {
switch (data.getEventType()) { switch (data.getEventType()) {
case RS_ZK_REGION_CLOSING: case RS_ZK_REGION_CLOSING:
if (isOnDeadServer(regionInfo, deadServers)) { // If zk node of the region was updated by a live server skip this
// If was on dead server, its closed now. Force to OFFLINE and this // region and just add it into RIT.
if (isOnDeadServer(regionInfo, deadServers) &&
(data.getOrigin() == null || !serverManager.isServerOnline(data.getOrigin()))) {
// If was on dead server, its closed now. Force to OFFLINE and this
// will get it reassigned if appropriate // will get it reassigned if appropriate
forceOffline(regionInfo, data); forceOffline(regionInfo, data);
} else { } else {
@ -416,10 +419,10 @@ public class AssignmentManager extends ZooKeeperListener {
LOG.warn("Region in transition " + regionInfo.getEncodedName() + LOG.warn("Region in transition " + regionInfo.getEncodedName() +
" references a null server; letting RIT timeout so will be " + " references a null server; letting RIT timeout so will be " +
"assigned elsewhere"); "assigned elsewhere");
break; } else if (isOnDeadServer(regionInfo, deadServers) &&
} !serverManager.isServerOnline(sn)) {
if (isOnDeadServer(regionInfo, deadServers)) { // If was on a dead server, then its not open any more; needs
// If was on a dead server, then its not open any more; needs handling. // handling.
forceOffline(regionInfo, data); forceOffline(regionInfo, data);
} else { } else {
new OpenedRegionHandler(master, this, regionInfo, sn).process(); new OpenedRegionHandler(master, this, regionInfo, sn).process();
@ -1957,6 +1960,18 @@ public class AssignmentManager extends ZooKeeperListener {
Result result = region.getSecond(); Result result = region.getSecond();
// If region was in transition (was in zk) force it offline for reassign // If region was in transition (was in zk) force it offline for reassign
try { try {
RegionTransitionData data = ZKAssign.getData(watcher,
regionInfo.getEncodedName());
// If zk node of this region has been updated by a live server,
// we consider that this region is being handled.
// So we should skip it and process it in processRegionsInTransition.
if (data != null && data.getOrigin() != null &&
serverManager.isServerOnline(data.getOrigin())) {
LOG.info("The region " + regionInfo.getEncodedName()
+ "is being handled on " + data.getOrigin());
continue;
}
// Process with existing RS shutdown code // Process with existing RS shutdown code
boolean assign = boolean assign =
ServerShutdownHandler.processDeadRegion(regionInfo, result, this, ServerShutdownHandler.processDeadRegion(regionInfo, result, this,