Repository: hbase Updated Branches: refs/heads/branch-1.2 b41bf10ed -> edbf2754a
HBASE-15955 Disable action in CatalogJanitor#setEnabled should wait for active cleanup scan to finish (Stephen Yuan Jiang) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/edbf2754 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/edbf2754 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/edbf2754 Branch: refs/heads/branch-1.2 Commit: edbf2754a410d3a4496ba1c2c8f96c7919da50a8 Parents: b41bf10 Author: Stephen Yuan Jiang <syuanjiang...@gmail.com> Authored: Fri Jun 3 15:48:48 2016 -0700 Committer: Stephen Yuan Jiang <syuanjiang...@gmail.com> Committed: Fri Jun 3 15:57:11 2016 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/master/CatalogJanitor.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/edbf2754/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java index d43e71a..37779c1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java @@ -50,6 +50,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.PairOfSameType; +import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hbase.util.Triple; /** @@ -88,7 +89,17 @@ public class CatalogJanitor extends ScheduledChore { * @param enabled */ public boolean setEnabled(final boolean enabled) { - return this.enabled.getAndSet(enabled); + boolean alreadyEnabled = this.enabled.getAndSet(enabled); + // If disabling is requested on an already enabled chore, we could have an active + // scan still going on, callers might not be aware of that and do further action thinkng + // that no action would be from this chore. In this case, the right action is to wait for + // the active scan to complete before exiting this function. + if (!enabled && alreadyEnabled) { + while (alreadyRunning.get()) { + Threads.sleepWithoutInterrupt(100); + } + } + return alreadyEnabled; } boolean getEnabled() {