diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java index 3122513..24d00d7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java @@ -282,6 +282,7 @@ public class FSHLog implements WAL { private final int slowSyncNs; private final static Object [] NO_ARGS = new Object []{}; + // If live datanode count is lower than the default replicas value, // RollWriter will be triggered in each sync(So the RollWriter will be // triggered one by one in a short time). Using it as a workaround to slow @@ -2052,4 +2053,4 @@ public class FSHLog implements WAL { } return new DatanodeInfo[0]; } -} \ No newline at end of file +} diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFailedAppendAndSync.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFailedAppendAndSync.java index 945361f..dd5df79 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFailedAppendAndSync.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFailedAppendAndSync.java @@ -25,7 +25,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; -import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,13 +33,11 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.DroppedSnapshotException; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.regionserver.wal.FSHLog; -import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper; @@ -81,8 +78,6 @@ public class TestFailedAppendAndSync { public void setup() throws IOException { TEST_UTIL = HBaseTestingUtility.createLocalHTU(); CONF = TEST_UTIL.getConfiguration(); - // Disable block cache. - CONF.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0f); dir = TEST_UTIL.getDataTestDir("TestHRegion").toString(); tableName = TableName.valueOf(name.getMethodName()); } @@ -106,7 +101,6 @@ public class TestFailedAppendAndSync { */ @Test (timeout=300000) public void testLockupAroundBadAssignSync() throws IOException { - final AtomicLong rolls = new AtomicLong(0); // Dodgy WAL. Will throw exceptions when flags set. class DodgyFSLog extends FSHLog { volatile boolean throwSyncException = false; @@ -118,13 +112,6 @@ public class TestFailedAppendAndSync { } @Override - public byte[][] rollWriter(boolean force) throws FailedLogCloseException, IOException { - byte [][] regions = super.rollWriter(force); - rolls.getAndIncrement(); - return regions; - } - - @Override protected Writer createWriterInstance(Path path) throws IOException { final Writer w = super.createWriterInstance(path); return new Writer() { @@ -188,7 +175,7 @@ public class TestFailedAppendAndSync { } catch (IOException ioe) { fail(); } - long rollsCount = rolls.get(); + try { dodgyWAL.throwAppendException = true; dodgyWAL.throwSyncException = false; @@ -198,9 +185,6 @@ public class TestFailedAppendAndSync { } catch (IOException ioe) { threwOnAppend = true; } - while (rollsCount == rolls.get()) Threads.sleep(100); - rollsCount = rolls.get(); - // When we get to here.. we should be ok. A new WAL has been put in place. There were no // appends to sync. We should be able to continue. @@ -213,8 +197,6 @@ public class TestFailedAppendAndSync { } catch (IOException ioe) { threwOnBoth = true; } - while (rollsCount == rolls.get()) Threads.sleep(100); - // Again, all should be good. New WAL and no outstanding unsync'd edits so we should be able // to just continue. diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java index ce70682..38decd4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.regionserver; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.IOException; import java.util.ArrayList; @@ -34,7 +35,6 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellScanner; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.TableName; @@ -82,8 +82,6 @@ public class TestWALLockup { public void setup() throws IOException { TEST_UTIL = HBaseTestingUtility.createLocalHTU(); CONF = TEST_UTIL.getConfiguration(); - // Disable block cache. - CONF.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0f); dir = TEST_UTIL.getDataTestDir("TestHRegion").toString(); tableName = TableName.valueOf(name.getMethodName()); } @@ -142,10 +140,10 @@ public class TestWALLockup { protected void beforeWaitOnSafePoint() { if (throwException) { LOG.info("COUNTDOWN"); - // Don't countdown latch until someone waiting on it otherwise, the above - // afterCreatingZigZagLatch will get to the latch and no one will ever free it and we'll - // be stuck; test won't go down - while (this.latch.getCount() <= 0) Threads.sleep(1); + // Don't countdown latch until someone waiting on it. + while (this.latch.getCount() <= 0) { + Threads.sleep(10); + } this.latch.countDown(); } } @@ -243,8 +241,8 @@ public class TestWALLockup { try { region.flush(false); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + LOG.info("In flush", e); + fail(); } }; }; @@ -256,13 +254,21 @@ public class TestWALLockup { assertTrue(originalWAL != dodgyWAL.getCurrentFileName()); // Can I append to it? dodgyWAL.throwException = false; - region.put(put); + try { + region.put(put); + } catch (Exception e) { + LOG.info("In the put", e); + } } finally { // To stop logRoller, its server has to say it is stopped. Mockito.when(server.isStopped()).thenReturn(true); if (logRoller != null) logRoller.interrupt(); - if (region != null) region.close(); - if (dodgyWAL != null) dodgyWAL.close(); + try { + if (region != null) region.close(); + if (dodgyWAL != null) dodgyWAL.close(); + } catch (Exception e) { + LOG.info("On way out", e); + } } } @@ -276,4 +282,4 @@ public class TestWALLockup { getName(), CONF, false, Durability.SYNC_WAL, wal, COLUMN_FAMILY_BYTES); } -} \ No newline at end of file +}