Skip to content

Commit

Permalink
CorfuReplicationE2EIT: Make gRPC server side handlers singe-threaded (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
xcchang committed Jan 17, 2023
1 parent 7b04eb8 commit ece3c8b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.corfudb.runtime.proto.service.CorfuMessage;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;

/**
* Server GRPC Transport Adapter
Expand Down Expand Up @@ -36,7 +37,11 @@ public GRPCLogReplicationServerChannelAdapter(ServerContext serverContext, LogRe
super(serverContext, router);
this.service = new GRPCLogReplicationServerHandler(router);
this.port = Integer.parseInt((String) serverContext.getServerConfig().get("<port>"));
this.server = ServerBuilder.forPort(port).addService(service).build();
// The executor of GRPCLogReplicationServerHandler needs to be single-threaded, otherwise the ordering of
// requests and their acks cannot be guaranteed. By default, grpc utilizes thread-pool, so we need to provide
// a single-threaded executor here.
this.server = ServerBuilder.forPort(port).addService(service)
.executor(Executors.newSingleThreadScheduledExecutor()).build();
}

@Override
Expand Down

0 comments on commit ece3c8b

Please sign in to comment.