Skip to content

Commit

Permalink
test(506): regarded as a successful closure when session not found
Browse files Browse the repository at this point in the history
  • Loading branch information
lsytj0413 committed Feb 21, 2025
1 parent 81dd079 commit 0065e0b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions common/error_codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion oxia/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
14 changes: 9 additions & 5 deletions server/public_rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,15 @@ 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),
)
return nil, err
}

s.log.Warn("Session not found, it should already closed")
}
return res, nil
}
Expand Down
7 changes: 3 additions & 4 deletions server/session_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 0065e0b

Please # to comment.