Skip to content

Commit 6515ef7

Browse files
committed
HBASE-25749 Improved logging when interrupting active RPC handlers holding the region close lock
We should add the thread to regionlockholders map to make sure we have can track the threads holding a lock even if it is not interuuptable. When calling interrupt we will not interrupt such threads but will print warn with thread name to help with debugging
1 parent 7c21e71 commit 6515ef7

File tree

1 file changed

+10
-9
lines changed
  • hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver

1 file changed

+10
-9
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -8441,9 +8441,9 @@ public void startRegionOperation(Operation op) throws IOException {
84418441
// Update regionLockHolders ONLY for any startRegionOperation call that is invoked from
84428442
// an RPC handler
84438443
Thread thisThread = Thread.currentThread();
8444-
if (isInterruptableOp) {
8445-
regionLockHolders.put(thisThread, true);
8446-
}
8444+
8445+
regionLockHolders.put(thisThread, isInterruptableOp);
8446+
84478447
if (this.closed.get()) {
84488448
lock.readLock().unlock();
84498449
throw new NotServingRegionException(getRegionInfo().getRegionNameAsString() + " is closed");
@@ -8458,11 +8458,7 @@ public void startRegionOperation(Operation op) throws IOException {
84588458
coprocessorHost.postStartRegionOperation(op);
84598459
}
84608460
} catch (Exception e) {
8461-
if (isInterruptableOp) {
8462-
// would be harmless to remove what we didn't add but we know by 'isInterruptableOp'
8463-
// if we added this thread to regionLockHolders
8464-
regionLockHolders.remove(thisThread);
8465-
}
8461+
regionLockHolders.remove(thisThread);
84668462
lock.readLock().unlock();
84678463
throw new IOException(e);
84688464
}
@@ -8702,8 +8698,13 @@ private void interruptRegionOperations() {
87028698
for (Map.Entry<Thread, Boolean> entry : regionLockHolders.entrySet()) {
87038699
// An entry in this map will have a boolean value indicating if it is currently
87048700
// eligible for interrupt; if so, we should interrupt it.
8701+
Thread key = entry.getKey();
87058702
if (entry.getValue().booleanValue()) {
8706-
entry.getKey().interrupt();
8703+
key.interrupt();
8704+
} else {
8705+
String s = Threads.printStackTrace(key);
8706+
LOG.warn("Can't interrupt thread {} : holding lock. Stack trace : {}", key, s);
8707+
87078708
}
87088709
}
87098710
}

0 commit comments

Comments
 (0)