wchevreuil commented on a change in pull request #864: HBASE-23313 [hbck2]
setRegionState should update Master in-memory sta…
URL: https://github.com/apache/hbase/pull/864#discussion_r349715407
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
##########
@@ -2465,6 +2466,39 @@ public GetTableStateResponse
setTableStateInMeta(RpcController controller,
}
}
+ /**
+ * Update state of the region in meta only. This is required by hbck in some
situations to cleanup
+ * stuck assign/ unassign regions procedures for the table.
+ *
+ * @return previous state of the region
+ */
+ @Override
+ public MasterProtos.GetRegionStateResponse
setRegionStateInMeta(RpcController controller,
+ MasterProtos.SetRegionStateInMetaRequest request) throws ServiceException {
+ try {
+ RegionInfo info = this.master.getAssignmentManager().
+ loadRegionFromMeta(request.getRegionInfo().getRegionEncodedName());
+ LOG.trace("region info loaded from meta table: {}", info);
+ RegionState prevState =
this.master.getAssignmentManager().getRegionStates().
+ getRegionState(info);
+ RegionState newState = RegionState.convert(request.getRegionState());
+ LOG.info("{} set region={} state from {} to {}",
master.getClientIdAuditPrefix(),
+ info, prevState.getState(), newState.getState());
+ Put metaPut = MetaTableAccessor.makePutFromRegionInfo(info,
System.currentTimeMillis());
+ metaPut.addColumn(HConstants.CATALOG_FAMILY,
+ HConstants.STATE_QUALIFIER, Bytes.toBytes(newState.getState().name()));
+ List<Put> putList = new ArrayList<>();
+ putList.add(metaPut);
+ MetaTableAccessor.putsToMetaTable(this.master.getConnection(), putList);
+ //Loads from meta again to refresh AM cache with the new region state
+
this.master.getAssignmentManager().loadRegionFromMeta(info.getEncodedName());
+ return MasterProtos.GetRegionStateResponse.newBuilder().
+ setRegionState(prevState.convert()).build();
+ } catch (Exception e) {
+ throw new ServiceException(e);
+ }
Review comment:
Yeah, had thought about that after this commit. Let me refactor it to
receive list of region encoded names.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services