Skip to content

Commit

Permalink
HBASE-23596 HBCKServerCrashProcedure can double assign
Browse files Browse the repository at this point in the history
Change its behavior so it will use Regions found in
Master context or, if none found, only then will it
search hbase:meta for references. Normal operation
where we read Master context is usual and sufficient.
The scan of hbase:meta is only for case where Master
state has been corrupted and we need to clear out
'Unknown Servers'.
  • Loading branch information
saintstack committed Dec 20, 2019
1 parent 0a989ea commit a065dd3
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,41 @@ public HBCKServerCrashProcedure(final MasterProcedureEnv env, final ServerName s
public HBCKServerCrashProcedure() {}

/**
* Adds Regions found by super method any found scanning hbase:meta.
* If no Regions found in Master context, then we will search hbase:meta for references
* to the passed server. Operator may have passed ServerName because they have found
* references to 'Unknown Servers'. They are using HBCKSCP to clear them out.
*/
@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NP_NULL_ON_SOME_PATH_EXCEPTION",
justification="FindBugs seems confused on ps in below.")
List<RegionInfo> getRegionsOnCrashedServer(MasterProcedureEnv env) {
// Super can return immutable emptyList.
// Super will return an immutable list (empty if nothing on this server).
List<RegionInfo> ris = super.getRegionsOnCrashedServer(env);
if (!ris.isEmpty()) {
return ris;
}
// If NOT empty, then presume operator schedule an SCP because they are trying to
// purge 'Unknown Servers' -- servers that are neither online nor in dead servers
// list but that ARE in hbase:meta and so showing as unknown in places like the
// 'HBCK Report'.
List<Pair<RegionInfo, ServerName>> ps = null;
try {
ps = MetaTableAccessor.getTableRegionsAndLocations(env.getMasterServices().getConnection(),
null, false);
} catch (IOException ioe) {
LOG.warn("Failed get of all regions; continuing", ioe);
LOG.warn("Failed scan of hbase:meta for 'Unknown Servers'", ioe);
return ris;
}
if (ps == null || ps.isEmpty()) {
LOG.warn("No regions found in hbase:meta");
LOG.warn("No regions found scanning hbase:meta");
return ris;
}
List<RegionInfo> aggregate = ris == null || ris.isEmpty()?
new ArrayList<>(): new ArrayList<>(ris);
int before = aggregate.size();
// Use a Set here in case same Region in master memory and in hbase:meta (the usual case!).
// Otherwise, we will double-assign.
List<RegionInfo> aggregate = new ArrayList<>();
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;
LOG.info("Found {} mentions of {} in hbase:meta", aggregate.size(), getServerName());
return new ArrayList<RegionInfo>(aggregate);
}
}

0 comments on commit a065dd3

Please sign in to comment.