apurtell commented on a change in pull request #2574:
URL: https://github.com/apache/hbase/pull/2574#discussion_r512084799



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
##########
@@ -1679,22 +1688,82 @@ public void setTimeoutForWriteLock(long 
timeoutForWriteLock) {
       }
     }
 
-    if (timeoutForWriteLock == null
-        || timeoutForWriteLock == Long.MAX_VALUE) {
-      // block waiting for the lock for closing
-      lock.writeLock().lock(); // FindBugs: Complains 
UL_UNRELEASED_LOCK_EXCEPTION_PATH but seems fine
+    // Set the closing flag
+    // From this point new arrivals at the region lock will get NSRE.
+
+    this.closing.set(true);
+    LOG.info("Closing region {}", this);
+
+    // Acquire the close lock
+
+    // The configuration parameter CLOSE_WAIT_ABORT is overloaded to enable 
both
+    // the new regionserver abort condition and interrupts for running 
requests.
+    // If CLOSE_WAIT_ABORT is not enabled there is no change from earlier 
behavior,
+    // we will not attempt to interrupt threads servicing requests nor crash 
out
+    // the regionserver if something remains stubborn.
+
+    boolean canAbort = conf.getBoolean(CLOSE_WAIT_ABORT, 
DEFAULT_CLOSE_WAIT_ABORT);
+    boolean useTimedWait = false;
+    if (timeoutForWriteLock == null || timeoutForWriteLock == Long.MAX_VALUE) {
+      if (canAbort) {
+        timeoutForWriteLock = conf.getLong(CLOSE_WAIT_TIME, 
DEFAULT_CLOSE_WAIT_TIME);
+        useTimedWait = true;
+      }
     } else {
+      // convert legacy use of timeoutForWriteLock in seconds to new use in 
millis
+      timeoutForWriteLock = TimeUnit.SECONDS.toMillis(timeoutForWriteLock);

Review comment:
       Ok




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to