Fix status code

This commit is contained in:
Andrea Cavalli 2024-10-24 02:54:20 +02:00
parent 384382ce34
commit 9063159a64
2 changed files with 4 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import com.google.protobuf.ByteString;
import com.google.protobuf.UnsafeByteOperations; import com.google.protobuf.UnsafeByteOperations;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.Status.Code;
import io.grpc.StatusRuntimeException; import io.grpc.StatusRuntimeException;
import io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.NettyChannelBuilder;
import io.netty.channel.epoll.EpollDomainSocketChannel; import io.netty.channel.epoll.EpollDomainSocketChannel;
@ -580,7 +581,7 @@ public class GrpcConnection extends BaseConnection implements RocksDBAPI {
private static Throwable mapGrpcStatusError(@NotNull Throwable t) { private static Throwable mapGrpcStatusError(@NotNull Throwable t) {
if (t instanceof StatusRuntimeException statusRuntimeException if (t instanceof StatusRuntimeException statusRuntimeException
&& statusRuntimeException.getStatus() == Status.INTERNAL && statusRuntimeException.getStatus().getCode() == Code.INTERNAL
&& statusRuntimeException.getStatus().getDescription() != null && statusRuntimeException.getStatus().getDescription() != null
&& statusRuntimeException.getStatus().getDescription().startsWith(grpcRocksDbErrorPrefixString)) { && statusRuntimeException.getStatus().getDescription().startsWith(grpcRocksDbErrorPrefixString)) {
var desc = statusRuntimeException.getStatus().getDescription(); var desc = statusRuntimeException.getStatus().getDescription();

View File

@ -301,6 +301,7 @@ public class GrpcServer extends Server {
@Override @Override
public Mono<Changed> putGetChanged(PutRequest request) { public Mono<Changed> putGetChanged(PutRequest request) {
return executeSync(() -> { return executeSync(() -> {
if(true) throw new RocksDBRetryException();
try (var arena = Arena.ofConfined()) { try (var arena = Arena.ofConfined()) {
var changed = api.put(arena, var changed = api.put(arena,
request.getTransactionOrUpdateId(), request.getTransactionOrUpdateId(),
@ -564,7 +565,7 @@ public class GrpcServer extends Server {
@Override @Override
protected Throwable onErrorMap(Throwable throwable) { protected Throwable onErrorMap(Throwable throwable) {
var ex = handleError(throwable).asException(); var ex = handleError(throwable).asException();
if (ex.getStatus().getCode() == Code.INTERNAL && !(throwable instanceof RocksDBException)) { if (ex.getStatus().getCode() == Code.INTERNAL && !(throwable.getCause() instanceof RocksDBException)) {
LOG.error("Unexpected internal error during request", ex); LOG.error("Unexpected internal error during request", ex);
} }
return ex; return ex;