@@ -1826,6 +1826,11 @@ private Map<byte[], List<HStoreFile>> doClose(boolean abort, MonitoredTask statu
1826
1826
LOG .error (msg );
1827
1827
if (canAbort ) {
1828
1828
// If we failed to acquire the write lock, abort the server
1829
+ // print all thread stacks which are still holding locks and are the cause of RS abort
1830
+ for (Map .Entry <Thread , Boolean > rslocks : regionLockHolders .entrySet ()) {
1831
+ LOG .warn ("Thread still holding lock {} : Stack trace : {}" , rslocks .getKey (),
1832
+ Threads .printStackTrace (rslocks .getKey ()));
1833
+ }
1829
1834
rsServices .abort (msg , null );
1830
1835
}
1831
1836
throw new IOException (msg );
@@ -8441,9 +8446,9 @@ public void startRegionOperation(Operation op) throws IOException {
8441
8446
// Update regionLockHolders ONLY for any startRegionOperation call that is invoked from
8442
8447
// an RPC handler
8443
8448
Thread thisThread = Thread .currentThread ();
8444
- if ( isInterruptableOp ) {
8445
- regionLockHolders .put (thisThread , true );
8446
- }
8449
+
8450
+ regionLockHolders .put (thisThread , isInterruptableOp );
8451
+
8447
8452
if (this .closed .get ()) {
8448
8453
lock .readLock ().unlock ();
8449
8454
throw new NotServingRegionException (getRegionInfo ().getRegionNameAsString () + " is closed" );
@@ -8458,11 +8463,7 @@ public void startRegionOperation(Operation op) throws IOException {
8458
8463
coprocessorHost .postStartRegionOperation (op );
8459
8464
}
8460
8465
} 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
- }
8466
+ regionLockHolders .remove (thisThread );
8466
8467
lock .readLock ().unlock ();
8467
8468
throw new IOException (e );
8468
8469
}
@@ -8702,8 +8703,13 @@ private void interruptRegionOperations() {
8702
8703
for (Map .Entry <Thread , Boolean > entry : regionLockHolders .entrySet ()) {
8703
8704
// An entry in this map will have a boolean value indicating if it is currently
8704
8705
// eligible for interrupt; if so, we should interrupt it.
8706
+ Thread key = entry .getKey ();
8705
8707
if (entry .getValue ().booleanValue ()) {
8706
- entry .getKey ().interrupt ();
8708
+ key .interrupt ();
8709
+ } else {
8710
+ String s = Threads .printStackTrace (key );
8711
+ LOG .warn ("Can't interrupt thread {} : holding lock. Stack trace : {}" , key , s );
8712
+
8707
8713
}
8708
8714
}
8709
8715
}
0 commit comments