Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: advance ServerStart check #8951

Merged
merged 8 commits into from
Jan 2, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@
// GetMinTSFromTSOService queries all tso servers and gets the minimum timestamp across
// all keyspace groups.
func (s *GrpcServer) GetMinTSFromTSOService() (*pdpb.Timestamp, error) {
if s.IsClosed() {
return nil, errs.ErrNotStarted
}

Check warning on line 330 in server/grpc_service.go

View check run for this annotation

Codecov / codecov/patch

server/grpc_service.go#L329-L330

Added lines #L329 - L330 were not covered by tests
addrs := s.keyspaceGroupManager.GetTSOServiceAddrs()
if len(addrs) == 0 {
return &pdpb.Timestamp{}, errs.ErrGetMinTS.FastGenByArgs("no tso servers/pods discovered")
Expand Down Expand Up @@ -536,6 +539,11 @@
return errors.WithStack(err)
}

// TSO uses leader lease to determine validity. No need to check leader here.
if s.IsClosed() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 2bd964d

return errs.ErrNotStarted
}

forwardedHost := grpcutil.GetForwardedHost(stream.Context())
if !s.isLocalRequest(forwardedHost) {
clientConn, err := s.getDelegateClient(s.ctx, forwardedHost)
Expand Down Expand Up @@ -570,10 +578,6 @@
}

start := time.Now()
// TSO uses leader lease to determine validity. No need to check leader here.
if s.IsClosed() {
return errs.ErrNotStarted
}
if clusterID := keypath.ClusterID(); request.GetHeader().GetClusterId() != clusterID {
return errs.ErrMismatchClusterID(clusterID, request.GetHeader().GetClusterId())
}
Expand Down Expand Up @@ -710,6 +714,9 @@
return nil, errs.ErrGRPCRateLimitExceeded(err)
}
}
if s.IsClosed() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe placing this check to the head of this function is better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other functions' checking IsClosed() is inside unaryMiddleware. All of the unaryMiddleware is behind Ratelimit component. So here it is consistent with other places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uploading image.png…

return nil, errs.ErrNotStarted
}

Check warning on line 719 in server/grpc_service.go

View check run for this annotation

Codecov / codecov/patch

server/grpc_service.go#L718-L719

Added lines #L718 - L719 were not covered by tests
// recovering mark is stored in etcd directly, there's no need to forward.
marked, err := s.Server.IsSnapshotRecovering(ctx)
if err != nil {
Expand Down
Loading