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

View File

@ -301,6 +301,7 @@ public class GrpcServer extends Server {
@Override
public Mono<Changed> putGetChanged(PutRequest request) {
return executeSync(() -> {
if(true) throw new RocksDBRetryException();
try (var arena = Arena.ofConfined()) {
var changed = api.put(arena,
request.getTransactionOrUpdateId(),
@ -564,7 +565,7 @@ public class GrpcServer extends Server {
@Override
protected Throwable onErrorMap(Throwable throwable) {
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);
}
return ex;