HBASE-17445 Count size of serialized exceptions in checking max result size quota

This commit is contained in:
tedyu 2017-01-11 10:06:40 -08:00
parent 2f7ce65b81
commit 56f963f4a6
3 changed files with 26 additions and 4 deletions

View File

@ -86,6 +86,9 @@ public interface RpcCallContext {
long getResponseBlockSize();
void incrementResponseBlockSize(long blockSize);
long getResponseExceptionSize();
void incrementResponseExceptionSize(long exceptionSize);
/**
* Return the deadline of this call. If we can not complete this call in time, we can throw a
* TimeoutIOException and RPCServer will drop it.

View File

@ -348,6 +348,8 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
private long responseCellSize = 0;
private long responseBlockSize = 0;
// cumulative size of serialized exceptions
private long exceptionSize = 0;
private boolean retryImmediatelySupported;
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NP_NULL_ON_SOME_PATH",
@ -563,6 +565,15 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
}
}
@Override
public long getResponseExceptionSize() {
return exceptionSize;
}
@Override
public void incrementResponseExceptionSize(long exSize) {
exceptionSize += exSize;
}
public long getSize() {
return this.size;
}

View File

@ -156,6 +156,7 @@ import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ResultOrException
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameInt64Pair;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionInfo;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
@ -657,7 +658,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
if (context != null
&& context.isRetryImmediatelySupported()
&& (context.getResponseCellSize() > maxQuotaResultSize
|| context.getResponseBlockSize() > maxQuotaResultSize)) {
|| context.getResponseBlockSize() + context.getResponseExceptionSize()
> maxQuotaResultSize)) {
// We're storing the exception since the exception and reason string won't
// change after the response size limit is reached.
@ -680,7 +682,9 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
//
// This will create a copy in the builder.
hasResultOrException = true;
resultOrExceptionBuilder.setException(ResponseConverter.buildException(sizeIOE));
NameBytesPair pair = ResponseConverter.buildException(sizeIOE);
resultOrExceptionBuilder.setException(pair);
context.incrementResponseExceptionSize(pair.getSerializedSize());
resultOrExceptionBuilder.setIndex(action.getIndex());
builder.addResultOrException(resultOrExceptionBuilder.build());
if (cellScanner != null) {
@ -712,7 +716,9 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
.setValue(result.toByteString())));
} catch (IOException ioe) {
rpcServer.getMetrics().exception(ioe);
resultOrExceptionBuilder.setException(ResponseConverter.buildException(ioe));
NameBytesPair pair = ResponseConverter.buildException(ioe);
resultOrExceptionBuilder.setException(pair);
context.incrementResponseExceptionSize(pair.getSerializedSize());
}
} else if (action.hasMutation()) {
MutationType type = action.getMutation().getMutateType();
@ -766,7 +772,9 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
} catch (IOException ie) {
rpcServer.getMetrics().exception(ie);
hasResultOrException = true;
resultOrExceptionBuilder.setException(ResponseConverter.buildException(ie));
NameBytesPair pair = ResponseConverter.buildException(ie);
resultOrExceptionBuilder.setException(pair);
context.incrementResponseExceptionSize(pair.getSerializedSize());
}
if (hasResultOrException) {
// Propagate index.