HBASE-19608 Race in MasterRpcServices.getProcedureResult
This commit is contained in:
parent
93870dc08d
commit
33f2e6535c
|
@ -70,6 +70,7 @@ import org.apache.hadoop.hbase.procedure.MasterProcedureManager;
|
||||||
import org.apache.hadoop.hbase.procedure2.LockType;
|
import org.apache.hadoop.hbase.procedure2.LockType;
|
||||||
import org.apache.hadoop.hbase.procedure2.LockedResource;
|
import org.apache.hadoop.hbase.procedure2.LockedResource;
|
||||||
import org.apache.hadoop.hbase.procedure2.Procedure;
|
import org.apache.hadoop.hbase.procedure2.Procedure;
|
||||||
|
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
|
||||||
import org.apache.hadoop.hbase.procedure2.ProcedureUtil;
|
import org.apache.hadoop.hbase.procedure2.ProcedureUtil;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
|
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsService;
|
import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsService;
|
||||||
|
@ -1153,35 +1154,28 @@ public class MasterRpcServices extends RSRpcServices
|
||||||
try {
|
try {
|
||||||
master.checkInitialized();
|
master.checkInitialized();
|
||||||
GetProcedureResultResponse.Builder builder = GetProcedureResultResponse.newBuilder();
|
GetProcedureResultResponse.Builder builder = GetProcedureResultResponse.newBuilder();
|
||||||
|
long procId = request.getProcId();
|
||||||
Procedure<?> result = master.getMasterProcedureExecutor()
|
ProcedureExecutor<?> executor = master.getMasterProcedureExecutor();
|
||||||
.getResultOrProcedure(request.getProcId());
|
Procedure<?> result = executor.getResultOrProcedure(procId);
|
||||||
if (result == null) {
|
if (result != null) {
|
||||||
builder.setState(GetProcedureResultResponse.State.NOT_FOUND);
|
builder.setSubmittedTime(result.getSubmittedTime());
|
||||||
} else {
|
builder.setLastUpdate(result.getLastUpdate());
|
||||||
boolean remove = false;
|
if (executor.isFinished(procId)) {
|
||||||
|
|
||||||
if (result.isFinished() || result.isFailed()) {
|
|
||||||
builder.setState(GetProcedureResultResponse.State.FINISHED);
|
builder.setState(GetProcedureResultResponse.State.FINISHED);
|
||||||
remove = true;
|
if (result.isFailed()) {
|
||||||
|
IOException exception = result.getException().unwrapRemoteIOException();
|
||||||
|
builder.setException(ForeignExceptionUtil.toProtoForeignException(exception));
|
||||||
|
}
|
||||||
|
byte[] resultData = result.getResult();
|
||||||
|
if (resultData != null) {
|
||||||
|
builder.setResult(UnsafeByteOperations.unsafeWrap(resultData));
|
||||||
|
}
|
||||||
|
master.getMasterProcedureExecutor().removeResult(request.getProcId());
|
||||||
} else {
|
} else {
|
||||||
builder.setState(GetProcedureResultResponse.State.RUNNING);
|
builder.setState(GetProcedureResultResponse.State.RUNNING);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
builder.setSubmittedTime(result.getSubmittedTime());
|
builder.setState(GetProcedureResultResponse.State.NOT_FOUND);
|
||||||
builder.setLastUpdate(result.getLastUpdate());
|
|
||||||
if (result.isFailed()) {
|
|
||||||
IOException exception = result.getException().unwrapRemoteIOException();
|
|
||||||
builder.setException(ForeignExceptionUtil.toProtoForeignException(exception));
|
|
||||||
}
|
|
||||||
byte[] resultData = result.getResult();
|
|
||||||
if (resultData != null) {
|
|
||||||
builder.setResult(UnsafeByteOperations.unsafeWrap(resultData));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remove) {
|
|
||||||
master.getMasterProcedureExecutor().removeResult(request.getProcId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Reference in New Issue