diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/HBCKServerCrashProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/HBCKServerCrashProcedure.java index 874dcde19861..34079ee8d335 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/HBCKServerCrashProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/HBCKServerCrashProcedure.java @@ -19,7 +19,9 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.ServerName; @@ -84,12 +86,12 @@ List getRegionsOnCrashedServer(MasterProcedureEnv env) { LOG.warn("No regions found in hbase:meta"); return ris; } - List aggregate = ris == null || ris.isEmpty()? - new ArrayList<>(): new ArrayList<>(ris); + // Use a Set here in case same Region in master memory and in hbase:meta (the usual case!). + Set aggregate = ris == null || ris.isEmpty()? new HashSet<>(): new HashSet<>(ris); int before = aggregate.size(); ps.stream().filter(p -> p.getSecond() != null && p.getSecond().equals(getServerName())). forEach(p -> aggregate.add(p.getFirst())); LOG.info("Found {} mentions of {} in hbase:meta", aggregate.size() - before, getServerName()); - return aggregate; + return new ArrayList(aggregate); } }