diff --git src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java index 3507c0d..dcce4e1 100644 --- src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java +++ src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java @@ -201,17 +201,24 @@ class SplitTransaction { throw new SplitAndCloseWriteLockNotHeld(); } - // We'll need one of these later but get it now because if we fail there - // is nothing to undo. + List hstoreFilesToSplit = this.parent.close(false); + this.journal.add(JournalEntry.CLOSED_PARENT_REGION); + + // Now that we've flagged the parent as 'closing' we can drop the + // write lock, since anyone else acquiring it after us will see + // that it's closing + this.parent.lock.writeLock().unlock(); + + // Vital to get the HTable after we've unlocked the region, since this + // starts an IPC connection to the server hosting META and/or ROOT, + // and that server may be this current one, in which case holding a lock + // might cause a deadlock (see HBASE-2964) HTable t = null; if (updateMeta) t = getTable(this.parent.getConf()); createSplitDir(this.parent.getFilesystem(), this.splitdir); this.journal.add(JournalEntry.CREATE_SPLIT_DIR); - List hstoreFilesToSplit = this.parent.close(false); - this.journal.add(JournalEntry.CLOSED_PARENT_REGION); - if (or != null) or.removeFromOnlineRegions(this.parent.getRegionInfo()); this.journal.add(JournalEntry.OFFLINED_PARENT); @@ -272,9 +279,6 @@ class SplitTransaction { // running a buffer -- its immediately flushing its puts. if (t != null) t.close(); - // Unlock if successful split. - this.parent.lock.writeLock().unlock(); - // Leaving here, the splitdir with its dross will be in place but since the // split was successful, just leave it; it'll be cleaned when parent is // deleted and cleaned up. @@ -537,4 +541,4 @@ class SplitTransaction { cleanupSplitDir(r.getFilesystem(), splitdir); LOG.info("Cleaned up old failed split transaction detritus: " + splitdir); } -} \ No newline at end of file +}