HBASE-2755 Duplicate assignment of a region after region server recovery

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@980649 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-07-30 04:57:44 +00:00
parent 3f2942ae4e
commit 2d214ccc52
2 changed files with 29 additions and 9 deletions

View File

@ -461,6 +461,8 @@ Release 0.21.0 - Unreleased
HBASE-2884 TestHFileOutputFormat flaky when map tasks generate identical HBASE-2884 TestHFileOutputFormat flaky when map tasks generate identical
data data
HBASE-2890 Initialize RPC JMX metrics on startup (Gary Helmling via Stack) HBASE-2890 Initialize RPC JMX metrics on startup (Gary Helmling via Stack)
HBASE-2755 Duplicate assignment of a region after region server recovery
(Kannan Muthukkaruppan via Stack)
IMPROVEMENTS IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable HBASE-1760 Cleanup TODOs in HTable

View File

@ -194,7 +194,7 @@ abstract class BaseScanner extends Chore {
long startCode = getStartCode(values); long startCode = getStartCode(values);
// Note Region has been assigned. // Note Region has been assigned.
checkAssigned(regionServer, region, info, serverAddress, startCode); checkAssigned(regionServer, region, info, serverAddress, startCode, true);
if (isSplitParent(info)) { if (isSplitParent(info)) {
splitParents.put(info, values); splitParents.put(info, values);
} }
@ -533,12 +533,15 @@ abstract class BaseScanner extends Chore {
* @param info * @param info
* @param hostnameAndPort hostname ':' port as it comes out of .META. * @param hostnameAndPort hostname ':' port as it comes out of .META.
* @param startCode * @param startCode
* @param checkTwice should we check twice before adding a region
* to unassigned pool.
* @throws IOException * @throws IOException
*/ */
protected void checkAssigned(final HRegionInterface regionServer, protected void checkAssigned(final HRegionInterface regionServer,
final MetaRegion meta, final HRegionInfo info, final MetaRegion meta, final HRegionInfo info,
final String hostnameAndPort, final long startCode) final String hostnameAndPort, final long startCode, boolean checkTwice)
throws IOException { throws IOException {
boolean tryAgain = false;
String serverName = null; String serverName = null;
String sa = hostnameAndPort; String sa = hostnameAndPort;
long sc = startCode; long sc = startCode;
@ -575,7 +578,9 @@ abstract class BaseScanner extends Chore {
// If we can't find the HServerInfo, then add it to the list of // If we can't find the HServerInfo, then add it to the list of
// unassigned regions. // unassigned regions.
if (storedInfo == null) { if (storedInfo == null) {
// The current assignment is invalid if (checkTwice) {
tryAgain = true;
} else {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Current assignment of " + info.getRegionNameAsString() + LOG.debug("Current assignment of " + info.getRegionNameAsString() +
" is not valid; " + " serverAddress=" + sa + " is not valid; " + " serverAddress=" + sa +
@ -586,6 +591,19 @@ abstract class BaseScanner extends Chore {
} }
} }
} }
if (tryAgain) {
// The current assignment is invalid. But we need to try again.
if (LOG.isDebugEnabled()) {
LOG.debug("Current assignment of " + info.getRegionNameAsString() +
" is not valid; " + " serverAddress=" + sa +
", startCode=" + sc + " unknown; checking once more!");
}
// passing null for hostNameAndPort will force the function
// to reget the assignment from META and protect against
// double assignment race conditions (HBASE-2755).
checkAssigned(regionServer, meta, info, null, 0, false);
}
}
/** /**
* Interrupt thread regardless of what it's doing * Interrupt thread regardless of what it's doing