You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bu...@apache.org on 2020/07/30 20:10:56 UTC
[hbase] branch branch-1.4 updated: HBASE-24794
hbase.rowlock.wait.duration should not be <= 0 (#2174)
This is an automated email from the ASF dual-hosted git repository.
busbey pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-1.4 by this push:
new 80dd0e7 HBASE-24794 hbase.rowlock.wait.duration should not be <= 0 (#2174)
80dd0e7 is described below
commit 80dd0e702194740925709ac3cb7e83ee01e6fdff
Author: Sean Busbey <bu...@apache.org>
AuthorDate: Thu Jul 30 12:26:12 2020 -0500
HBASE-24794 hbase.rowlock.wait.duration should not be <= 0 (#2174)
if hbase.rowlock.wait.duration is <=0 then log a message and treat it as a value of 1ms.
amended for branches-1
Signed-off-by: Viraj Jasani <vj...@apache.org>
(cherry picked from commit 840a55761b4b3db6bfcf8ca5b7ae67509fc21566)
(cherry picked from commit 51161b5f4816374683fa7d158103fde6d88f19bb)
---
.../apache/hadoop/hbase/regionserver/HRegion.java | 10 +++-
.../hadoop/hbase/regionserver/TestHRegion.java | 62 ++++++++++++++++++++++
2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 773d61f..f4796a2 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -757,8 +757,14 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
throw new IllegalArgumentException(MEMSTORE_FLUSH_PER_CHANGES + " can not exceed "
+ MAX_FLUSH_PER_CHANGES);
}
- this.rowLockWaitDuration = conf.getInt("hbase.rowlock.wait.duration",
- DEFAULT_ROWLOCK_WAIT_DURATION);
+ int tmpRowLockDuration = conf.getInt("hbase.rowlock.wait.duration",
+ DEFAULT_ROWLOCK_WAIT_DURATION);
+ if (tmpRowLockDuration <= 0) {
+ LOG.info("Found hbase.rowlock.wait.duration set to " + tmpRowLockDuration + ". values <= 0 " +
+ "will cause all row locking to fail. Treating it as 1ms to avoid region failure.");
+ tmpRowLockDuration = 1;
+ }
+ this.rowLockWaitDuration = tmpRowLockDuration;
this.maxWaitForSeqId = conf.getInt(MAX_WAIT_FOR_SEQ_ID_KEY, DEFAULT_MAX_WAIT_FOR_SEQ_ID);
this.isLoadingCfsOnDemandDefault = conf.getBoolean(LOAD_CFS_ON_DEMAND_CONFIG_KEY, true);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
index fdf094c..d9bdfb6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
@@ -6356,6 +6356,68 @@ public class TestHRegion {
}
@Test
+ public void testBatchMutateWithZeroRowLockWait() throws Exception {
+ final byte[] a = Bytes.toBytes("a");
+ final byte[] b = Bytes.toBytes("b");
+ final byte[] c = Bytes.toBytes("c"); // exclusive
+
+ Configuration conf = new Configuration(CONF);
+ conf.setInt("hbase.rowlock.wait.duration", 0);
+ final HRegionInfo hri = new HRegionInfo(TableName.valueOf(tableName), a, c);
+ final HTableDescriptor htd = new HTableDescriptor(tableName);
+ htd.addFamily(new HColumnDescriptor(fam1));
+ region = HRegion.createHRegion(hri, TEST_UTIL.getDataTestDir(), conf, htd, TEST_UTIL.createWal(conf, TEST_UTIL.getDataTestDir(), TEST_UTIL.getDataTestDirOnTestFS(method + ".log"), hri));
+
+ Mutation[] mutations = new Mutation[] {
+ new Put(a).addImmutable(fam1, null, null),
+ new Put(b).addImmutable(fam1, null, null),
+ };
+
+ OperationStatus[] status = region.batchMutate(mutations);
+ assertEquals(OperationStatusCode.SUCCESS, status[0].getOperationStatusCode());
+ assertEquals(OperationStatusCode.SUCCESS, status[1].getOperationStatusCode());
+
+
+ // test with a row lock held for a long time
+ final CountDownLatch obtainedRowLock = new CountDownLatch(1);
+ ExecutorService exec = Executors.newFixedThreadPool(2);
+ Future<Void> f1 = exec.submit(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ LOG.info("Acquiring row lock");
+ RowLock rl = region.getRowLock(b);
+ obtainedRowLock.countDown();
+ LOG.info("Waiting for 5 seconds before releasing lock");
+ Threads.sleep(5000);
+ LOG.info("Releasing row lock");
+ rl.release();
+ return null;
+ }
+ });
+ obtainedRowLock.await(30, TimeUnit.SECONDS);
+
+ Future<Void> f2 = exec.submit(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ Mutation[] mutations = new Mutation[] {
+ new Put(a).addImmutable(fam1, null, null),
+ new Put(b).addImmutable(fam1, null, null),
+ };
+ // when handling row b we are going to spin on the failure to get the row lock
+ // until the lock above is released, but we will still succeed so long as that
+ // takes less time then the test time out.
+ OperationStatus[] status = region.batchMutate(mutations);
+ assertEquals(OperationStatusCode.SUCCESS, status[0].getOperationStatusCode());
+ assertEquals(OperationStatusCode.SUCCESS, status[1].getOperationStatusCode());
+ return null;
+ }
+ });
+
+ f1.get();
+ f2.get();
+ }
+
+ @Test
public void testCheckAndRowMutateTimestampsAreMonotonic() throws IOException {
region = initHRegion(tableName, name.getMethodName(), CONF, fam1);
ManualEnvironmentEdge edge = new ManualEnvironmentEdge();