HBASE-8164 TestTableLockManager fails intermittently in trunk builds

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1463194 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2013-04-01 16:32:02 +00:00
parent d814bff215
commit 58ec4f8e68
2 changed files with 24 additions and 13 deletions

View File

@ -1943,15 +1943,20 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
attempted.clear(); attempted.clear();
} }
regCount = regions.size(); regCount = regions.size();
idx = random.nextInt(regions.size()); // There are chances that before we get the region for the table from an RS the region may
// if we have just tried this region, there is no need to try again // be going for CLOSE. This may be because online schema change is enabled
if (attempted.contains(idx)) continue; if (regCount > 0) {
try { idx = random.nextInt(regCount);
regions.get(idx).checkSplit(); // if we have just tried this region, there is no need to try again
return regions.get(idx); if (attempted.contains(idx))
} catch (Exception ex) { continue;
LOG.warn("Caught exception", ex); try {
attempted.add(idx); regions.get(idx).checkSplit();
return regions.get(idx);
} catch (Exception ex) {
LOG.warn("Caught exception", ex);
attempted.add(idx);
}
} }
attempts++; attempts++;
} while (maxAttempts == -1 || attempts < maxAttempts); } while (maxAttempts == -1 || attempts < maxAttempts);

View File

@ -355,10 +355,16 @@ public class TestTableLockManager {
public void chore() { public void chore() {
try { try {
HRegion region = TEST_UTIL.getSplittableRegion(tableName, -1); HRegion region = TEST_UTIL.getSplittableRegion(tableName, -1);
byte[] regionName = region.getRegionName(); if (region != null) {
admin.flush(regionName); byte[] regionName = region.getRegionName();
admin.compact(regionName); admin.flush(regionName);
admin.split(regionName); admin.compact(regionName);
admin.split(regionName);
} else {
LOG.warn("Could not find suitable region for the table. Possibly the " +
"region got closed and the attempts got over before " +
"the region could have got reassigned.");
}
} catch (NotServingRegionException nsre) { } catch (NotServingRegionException nsre) {
// the region may be in transition // the region may be in transition
LOG.warn("Caught exception", nsre); LOG.warn("Caught exception", nsre);