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) #8970

Merged
Merged
Changes from all 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 @@ -194,6 +194,9 @@ func (s *GrpcServer) GetMinTS(
// GetMinTSFromTSOService queries all tso servers and gets the minimum timestamp across
// all keyspace groups.
func (s *GrpcServer) GetMinTSFromTSOService(dcLocation string) (*pdpb.Timestamp, error) {
if s.IsClosed() {
return nil, ErrNotStarted
}
addrs := s.keyspaceGroupManager.GetTSOServiceAddrs()
if len(addrs) == 0 {
return &pdpb.Timestamp{}, errs.ErrGetMinTS.FastGenByArgs("no tso servers/pods discovered")
Expand Down Expand Up @@ -392,6 +395,10 @@ func (s *GrpcServer) Tso(stream pdpb.PD_TsoServer) error {
return errors.WithStack(err)
}

// TSO uses leader lease to determine validity. No need to check leader here.
if s.IsClosed() {
return ErrNotStarted
}
if forwardedHost, err := s.getForwardedHost(ctx, stream.Context()); err != nil {
return err
} else if len(forwardedHost) > 0 {
Expand All @@ -412,10 +419,7 @@ func (s *GrpcServer) Tso(stream pdpb.PD_TsoServer) error {
}

start := time.Now()
// TSO uses leader lease to determine validity. No need to check leader here.
if s.IsClosed() {
return status.Errorf(codes.Unknown, "server not started")
}

if request.GetHeader().GetClusterId() != s.clusterID {
return status.Errorf(codes.FailedPrecondition,
"mismatch cluster id, need %d but got %d", s.clusterID, request.GetHeader().GetClusterId())
Expand Down Expand Up @@ -779,6 +783,9 @@ func (s *GrpcServer) AllocID(ctx context.Context, request *pdpb.AllocIDRequest)

// IsSnapshotRecovering implements gRPC PDServer.
func (s *GrpcServer) IsSnapshotRecovering(ctx context.Context, request *pdpb.IsSnapshotRecoveringRequest) (*pdpb.IsSnapshotRecoveringResponse, error) {
if s.IsClosed() {
return nil, ErrNotStarted
}
// 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