HBASE-24099 Use a fair ReentrantReadWriteLock for the region close lock (#1407)

Signed-off-by: Michael Stack <stack@apache.org>
Signed-off-by: Xu Cang <xucang@apache.org>
Signed-off-by: Reid Chan <reidchan@apache.org>
Signed-off-by: Bharath Vissapragada <bharathv@apache.org>

Conflicts:
	hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
This commit is contained in:
Andrew Purtell 2020-04-08 11:36:48 -07:00
parent 776d75b9c0
commit 27f512d334
No known key found for this signature in database
GPG Key ID: 8597754DD5365CCD

View File

@ -661,8 +661,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
private long blockingMemStoreSize;
final long threadWakeFrequency;
// Used to guard closes
final ReentrantReadWriteLock lock =
new ReentrantReadWriteLock();
final ReentrantReadWriteLock lock;
// Stop updates lock
private final ReentrantReadWriteLock updatesLock =
@ -752,6 +751,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
.add(confParam)
.addStringMap(htd.getConfiguration())
.addWritableMap(htd.getValues());
this.lock = new ReentrantReadWriteLock(conf.getBoolean(FAIR_REENTRANT_CLOSE_LOCK,
DEFAULT_FAIR_REENTRANT_CLOSE_LOCK));
this.flushCheckInterval = conf.getInt(MEMSTORE_PERIODIC_FLUSH_INTERVAL,
DEFAULT_CACHE_FLUSH_INTERVAL);
this.flushPerChanges = conf.getLong(MEMSTORE_FLUSH_PER_CHANGES, DEFAULT_FLUSH_PER_CHANGES);
@ -1452,6 +1453,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
private final Object closeLock = new Object();
/** Conf key for fair locking policy */
public static final String FAIR_REENTRANT_CLOSE_LOCK =
"hbase.regionserver.fair.region.close.lock";
public static final boolean DEFAULT_FAIR_REENTRANT_CLOSE_LOCK = true;
/** Conf key for the periodic flush interval */
public static final String MEMSTORE_PERIODIC_FLUSH_INTERVAL =
"hbase.regionserver.optionalcacheflushinterval";