diff --git a/CHANGES.txt b/CHANGES.txt index cd913e73fcd..0e9edfdbaa5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -158,6 +158,7 @@ Release 0.91.0 - Unreleased RS entries in master (Weihua via Ted Yu) HBASE-4077 Deadlock if WrongRegionException is thrown from getLock in HRegion.delete (Adam Warrington via Ted Yu) + HBASE-3893 HRegion.internalObtainRowLock shouldn't wait forever IMPROVEMENTS HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index d401bd2e63d..75725d00dbf 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -42,6 +42,7 @@ import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -59,12 +60,12 @@ import org.apache.hadoop.hbase.DroppedSnapshotException; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; -import org.apache.hadoop.hbase.HConstants.OperationStatusCode; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.UnknownScannerException; +import org.apache.hadoop.hbase.HConstants.OperationStatusCode; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Increment; @@ -75,10 +76,10 @@ import org.apache.hadoop.hbase.client.RowLock; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.coprocessor.Exec; import org.apache.hadoop.hbase.client.coprocessor.ExecResult; -import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; import org.apache.hadoop.hbase.filter.Filter; import org.apache.hadoop.hbase.filter.IncompatibleFilterException; import org.apache.hadoop.hbase.filter.WritableByteArrayComparable; +import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; import org.apache.hadoop.hbase.io.HeapSize; import org.apache.hadoop.hbase.io.TimeRange; import org.apache.hadoop.hbase.io.hfile.BlockCache; @@ -90,18 +91,17 @@ import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest; import org.apache.hadoop.hbase.regionserver.wal.HLog; import org.apache.hadoop.hbase.regionserver.wal.HLogKey; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; -import org.apache.hadoop.hbase.util.HashedBytes; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.CancelableProgressable; import org.apache.hadoop.hbase.util.ClassSize; import org.apache.hadoop.hbase.util.CompressionTest; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.FSUtils; +import org.apache.hadoop.hbase.util.HashedBytes; import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.Writables; import org.apache.hadoop.io.Writable; import org.apache.hadoop.util.StringUtils; - import org.cliffc.high_scale_lib.Counter; import com.google.common.base.Preconditions; @@ -195,6 +195,8 @@ public class HRegion implements HeapSize { // , Writable{ final HLog log; final FileSystem fs; final Configuration conf; + final int rowLockWaitDuration; + static final int DEFAULT_ROWLOCK_WAIT_DURATION = 30000; final HRegionInfo regionInfo; final Path regiondir; KeyValue.KVComparator comparator; @@ -274,6 +276,7 @@ public class HRegion implements HeapSize { // , Writable{ this.tableDir = null; this.blockingMemStoreSize = 0L; this.conf = null; + this.rowLockWaitDuration = DEFAULT_ROWLOCK_WAIT_DURATION; this.rsServices = null; this.fs = null; this.memstoreFlushSize = 0L; @@ -316,6 +319,8 @@ public class HRegion implements HeapSize { // , Writable{ this.log = log; this.fs = fs; this.conf = conf; + this.rowLockWaitDuration = conf.getInt("hbase.rowlock.wait.duration", + DEFAULT_ROWLOCK_WAIT_DURATION); this.regionInfo = regionInfo; this.htableDescriptor = htd; this.rsServices = rsServices; @@ -2400,7 +2405,10 @@ public class HRegion implements HeapSize { // , Writable{ return null; } try { - existingLatch.await(); + if (!existingLatch.await(this.rowLockWaitDuration, + TimeUnit.MILLISECONDS)) { + return null; + } } catch (InterruptedException ie) { // Empty }