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>
This commit is contained in:
Andrew Purtell 2020-04-08 11:36:48 -07:00 committed by GitHub
parent 72727ff9be
commit ac6060c3f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -681,7 +681,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
private long flushPerChanges;
private long blockingMemStoreSize;
// Used to guard closes
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
final ReentrantReadWriteLock lock;
// Stop updates lock
private final ReentrantReadWriteLock updatesLock = new ReentrantReadWriteLock();
@ -772,6 +772,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
this.conf = new CompoundConfiguration()
.add(confParam)
.addBytesMap(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);
@ -1521,6 +1523,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";