Skip to content

Commit 62dd90b

Browse files
comnetworkApache9
andcommitted
HBASE-27231 FSHLog should retry writing WAL entries when syncs to HDFS failed.
Co-authored-by: Duo Zhang <zhangduo@apache.org>
1 parent b2e2abe commit 62dd90b

11 files changed

Lines changed: 1112 additions & 2124 deletions

File tree

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java

Lines changed: 730 additions & 22 deletions
Large diffs are not rendered by default.

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncFSWAL.java

Lines changed: 17 additions & 634 deletions
Large diffs are not rendered by default.

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java

Lines changed: 183 additions & 794 deletions
Large diffs are not rendered by default.

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFailedAppendAndSync.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.apache.hadoop.hbase.TableName;
4242
import org.apache.hadoop.hbase.client.Durability;
4343
import org.apache.hadoop.hbase.client.Put;
44+
import org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL;
4445
import org.apache.hadoop.hbase.regionserver.wal.FSHLog;
4546
import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException;
4647
import org.apache.hadoop.hbase.testclassification.SmallTests;
@@ -93,6 +94,7 @@ public void setup() throws IOException {
9394
CONF = TEST_UTIL.getConfiguration();
9495
// Disable block cache.
9596
CONF.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0f);
97+
CONF.setLong(AbstractFSWAL.WAL_SYNC_TIMEOUT_MS, 10000);
9698
dir = TEST_UTIL.getDataTestDir("TestHRegion").toString();
9799
tableName = TableName.valueOf(name.getMethodName());
98100
}
@@ -258,22 +260,16 @@ public void testLockupAroundBadAssignSync() throws IOException {
258260
dodgyWAL.throwSyncException = true;
259261
Put put = new Put(value);
260262
put.addColumn(COLUMN_FAMILY_BYTES, Bytes.toBytes("2"), value);
263+
region.rsServices = services;
261264
region.put(put);
262265
} catch (IOException ioe) {
263266
threwOnSync = true;
264267
}
265-
// An append in the WAL but the sync failed is a server abort condition. That is our
266-
// current semantic. Verify. It takes a while for abort to be called. Just hang here till it
267-
// happens. If it don't we'll timeout the whole test. That is fine.
268-
while (true) {
269-
try {
270-
verify(services, atLeast(1)).abort(anyString(), any(Throwable.class));
271-
break;
272-
} catch (WantedButNotInvoked t) {
273-
Threads.sleep(1);
274-
}
275-
}
276268

269+
region.rsServices = null;
270+
// An append in the WAL but the sync failed is a server abort condition. That is our
271+
// current semantic. Verify.
272+
verify(services, atLeast(1)).abort(anyString(), any());
277273
try {
278274
dodgyWAL.throwAppendException = false;
279275
dodgyWAL.throwSyncException = false;

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@
147147
import org.apache.hadoop.hbase.regionserver.Region.RowLock;
148148
import org.apache.hadoop.hbase.regionserver.TestHStore.FaultyFileSystem;
149149
import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequestImpl;
150+
import org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL;
151+
import org.apache.hadoop.hbase.regionserver.wal.AsyncFSWAL;
150152
import org.apache.hadoop.hbase.regionserver.wal.FSHLog;
151153
import org.apache.hadoop.hbase.regionserver.wal.MetricsWALSource;
152154
import org.apache.hadoop.hbase.regionserver.wal.WALUtil;
@@ -178,6 +180,7 @@
178180
import org.junit.Assert;
179181
import org.junit.Before;
180182
import org.junit.ClassRule;
183+
import org.junit.Ignore;
181184
import org.junit.Rule;
182185
import org.junit.Test;
183186
import org.junit.experimental.categories.Category;
@@ -260,6 +263,7 @@ public void setup() throws IOException {
260263
method = name.getMethodName();
261264
tableName = TableName.valueOf(method);
262265
CONF.set(CompactingMemStore.IN_MEMORY_FLUSH_THRESHOLD_FACTOR_KEY, String.valueOf(0.09));
266+
CONF.setLong(AbstractFSWAL.WAL_SYNC_TIMEOUT_MS, 10000);
263267
}
264268

265269
@After
@@ -5415,7 +5419,14 @@ public void testPutWithMemStoreFlush() throws Exception {
54155419
assertArrayEquals(Bytes.toBytes("value1"), CellUtil.cloneValue(kvs.get(0)));
54165420
}
54175421

5422+
/**
5423+
* For this test,the spied {@link AsyncFSWAL} can not work properly because of a Mockito defect
5424+
* that can not deal with classes which have a field of an inner class. See discussions in
5425+
* HBASE-15536.When we reuse the code of {@link AsyncFSWAL} for {@link FSHLog}, this test could
5426+
* not work for {@link FSHLog} also.
5427+
*/
54185428
@Test
5429+
@Ignore
54195430
public void testDurability() throws Exception {
54205431
// there are 5 x 5 cases:
54215432
// table durability(SYNC,FSYNC,ASYC,SKIP,USE_DEFAULT) x mutation
@@ -5469,6 +5480,7 @@ private void durabilityTest(String method, Durability tableDurability,
54695480
Durability mutationDurability, long timeout, boolean expectAppend, final boolean expectSync,
54705481
final boolean expectSyncFromLogSyncer) throws Exception {
54715482
Configuration conf = HBaseConfiguration.create(CONF);
5483+
conf.setLong(AbstractFSWAL.WAL_SHUTDOWN_WAIT_TIMEOUT_MS, 60 * 60 * 1000);
54725484
method = method + "_" + tableDurability.name() + "_" + mutationDurability.name();
54735485
byte[] family = Bytes.toBytes("family");
54745486
Path logDir = new Path(new Path(dir + method), "log");

0 commit comments

Comments
 (0)