diff --git a/common/error_codes.go b/common/error_codes.go index a8af6d20..7feb810e 100644 --- a/common/error_codes.go +++ b/common/error_codes.go @@ -28,7 +28,7 @@ const ( CodeLeaderAlreadyConnected codes.Code = 105 CodeNodeIsNotLeader codes.Code = 106 CodeNodeIsNotFollower codes.Code = 107 - CodeInvalidSession codes.Code = 108 + CodeSessionNotFound codes.Code = 108 CodeInvalidSessionTimeout codes.Code = 109 CodeNamespaceNotFound codes.Code = 110 CodeNotificationsNotEnabled codes.Code = 111 @@ -43,7 +43,7 @@ var ( ErrorAlreadyClosed = status.Error(CodeAlreadyClosed, "oxia: node is shutting down") ErrorNodeIsNotLeader = status.Error(CodeNodeIsNotLeader, "oxia: node is not leader for shard") ErrorNodeIsNotFollower = status.Error(CodeNodeIsNotFollower, "oxia: node is not follower for shard") - ErrorInvalidSession = status.Error(CodeInvalidSession, "oxia: session not found") + ErrorSessionNotFound = status.Error(CodeSessionNotFound, "oxia: session not found") ErrorInvalidSessionTimeout = status.Error(CodeInvalidSessionTimeout, "oxia: invalid session timeout") ErrorNamespaceNotFound = status.Error(CodeNamespaceNotFound, "oxia: namespace not found") ErrorNotificationsNotEnabled = status.Error(CodeNotificationsNotEnabled, "oxia: notifications not enabled on namespace") diff --git a/oxia/sessions.go b/oxia/sessions.go index 3242ff26..f90f7428 100644 --- a/oxia/sessions.go +++ b/oxia/sessions.go @@ -194,7 +194,7 @@ func (cs *clientSession) createSession() error { backOff := common.NewBackOff(cs.sessions.ctx) err := backoff.RetryNotify(func() error { err := cs.keepAlive() - if status.Code(err) == common.CodeInvalidSession { + if status.Code(err) == common.CodeSessionNotFound { cs.log.Error( "Session is no longer valid", slog.Any("error", err), diff --git a/server/public_rpc_server.go b/server/public_rpc_server.go index 770d5782..580e0c60 100644 --- a/server/public_rpc_server.go +++ b/server/public_rpc_server.go @@ -394,11 +394,14 @@ func (s *publicRpcServer) CloseSession(ctx context.Context, req *proto.CloseSess } res, err := lc.CloseSession(req) if err != nil { - s.log.Warn( - "Failed to close session", - slog.Any("error", err), - ) - return nil, err + if status.Code(err) != common.CodeSessionNotFound { + s.log.Warn( + "Failed to close session", + slog.Any("error", err), + ) + } + + s.log.Warn("Session not found, it should already closed") } return res, nil } diff --git a/server/session_manager.go b/server/session_manager.go index 8d9bd134..cbc206cf 100644 --- a/server/session_manager.go +++ b/server/session_manager.go @@ -17,18 +17,17 @@ package server import ( "context" "fmt" - "github.com/streamnative/oxia/common/collection" "io" "log/slog" "net/url" "sync" "time" - "go.uber.org/multierr" - "github.com/pkg/errors" + "go.uber.org/multierr" "github.com/streamnative/oxia/common" + "github.com/streamnative/oxia/common/collection" "github.com/streamnative/oxia/common/metrics" "github.com/streamnative/oxia/proto" "github.com/streamnative/oxia/server/kv" @@ -177,7 +176,7 @@ func (sm *sessionManager) getSession(sessionId int64) (*session, error) { "Session not found", slog.Int64("session-id", sessionId), ) - return nil, common.ErrorInvalidSession + return nil, common.ErrorSessionNotFound } return s, nil }