diff --git a/server/internal_rpc_server.go b/server/internal_rpc_server.go index c3ce163b..b9791d99 100644 --- a/server/internal_rpc_server.go +++ b/server/internal_rpc_server.go @@ -172,14 +172,14 @@ func (s *internalRpcServer) BecomeLeader(c context.Context, req *proto.BecomeLea return nil, err } - res, err2 := leader.BecomeLeader(c, req) - if err2 != nil { + res, err := leader.BecomeLeader(c, req) + if err != nil { log.Warn( "BecomeLeader failed", slog.Any("error", err), ) } - return res, err2 + return res, err } func (s *internalRpcServer) AddFollower(c context.Context, req *proto.AddFollowerRequest) (*proto.AddFollowerResponse, error) { @@ -199,14 +199,14 @@ func (s *internalRpcServer) AddFollower(c context.Context, req *proto.AddFollowe return nil, err } - res, err2 := leader.AddFollower(req) - if err2 != nil { + res, err := leader.AddFollower(req) + if err != nil { log.Warn( "AddFollower failed", slog.Any("error", err), ) } - return res, err2 + return res, err } func (s *internalRpcServer) Truncate(c context.Context, req *proto.TruncateRequest) (*proto.TruncateResponse, error) { @@ -226,12 +226,14 @@ func (s *internalRpcServer) Truncate(c context.Context, req *proto.TruncateReque return nil, err } - res, err2 := follower.Truncate(req) - log.Warn( - "Truncate failed", - slog.Any("error", err), - ) - return res, err2 + res, err := follower.Truncate(req) + if err != nil { + log.Warn( + "Truncate failed", + slog.Any("error", err), + ) + } + return res, err } func (s *internalRpcServer) Replicate(srv proto.OxiaLogReplication_ReplicateServer) error { @@ -274,14 +276,14 @@ func (s *internalRpcServer) Replicate(srv proto.OxiaLogReplication_ReplicateServ return err } - err2 := follower.Replicate(srv) - if err2 != nil && !errors.Is(err2, io.EOF) { + err = follower.Replicate(srv) + if err != nil && !errors.Is(err, io.EOF) { log.Warn( "Replicate failed", slog.Any("error", err), ) } - return err2 + return err } func (s *internalRpcServer) SendSnapshot(srv proto.OxiaLogReplication_SendSnapshotServer) error { @@ -326,8 +328,8 @@ func (s *internalRpcServer) SendSnapshot(srv proto.OxiaLogReplication_SendSnapsh return err } - err2 := follower.SendSnapshot(srv) - if err2 != nil { + err = follower.SendSnapshot(srv) + if err != nil { s.log.Warn( "SendSnapshot failed", slog.Any("error", err), @@ -336,7 +338,7 @@ func (s *internalRpcServer) SendSnapshot(srv proto.OxiaLogReplication_SendSnapsh slog.String("peer", common.GetPeer(srv.Context())), ) } - return err2 + return err } func (s *internalRpcServer) GetStatus(_ context.Context, req *proto.GetStatusRequest) (*proto.GetStatusResponse, error) {