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: pause scheduling immediately #7809

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion server/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"github.com/tikv/pd/pkg/utils/grpcutil"
"github.com/tikv/pd/pkg/utils/logutil"
"github.com/tikv/pd/pkg/utils/tsoutil"
"github.com/tikv/pd/server/cluster"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -249,7 +250,7 @@
return forwardStream, forwardCtx, cancelForward, err
}

func forwardRegionHeartbeatToScheduling(forwardStream schedulingpb.Scheduling_RegionHeartbeatClient, server *heartbeatServer, errCh chan error) {
func forwardRegionHeartbeatToScheduling(rc *cluster.RaftCluster, forwardStream schedulingpb.Scheduling_RegionHeartbeatClient, server *heartbeatServer, errCh chan error) {
defer logutil.LogPanic()
defer close(errCh)
for {
Expand All @@ -262,6 +263,10 @@
errCh <- errors.WithStack(err)
return
}
// TODO: find a better way to halt scheduling immediately.
if rc.GetOpts().IsSchedulingHalted() {
continue

Check warning on line 268 in server/forward.go

View check run for this annotation

Codecov / codecov/patch

server/forward.go#L268

Added line #L268 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

One problem is that the operator generated by the scheduling server still exists in memory. Is it possible to cancel all the scheduling server operators after the online recovery is complete so that the scheduling can be resumed as soon as possible?

Copy link
Member Author

@rleungx rleungx Feb 7, 2024

Choose a reason for hiding this comment

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

It depends. IMO, if those operators still take effect, cancelling all is not the best way. But if the region is changed, we may need to cancel. So I prefer to leave it for now.

}
// The error types defined for schedulingpb and pdpb are different, so we need to convert them.
var pdpbErr *pdpb.Error
schedulingpbErr := resp.GetHeader().GetError()
Expand Down
2 changes: 1 addition & 1 deletion server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ func (s *GrpcServer) RegionHeartbeat(stream pdpb.PD_RegionHeartbeatServer) error
}
lastForwardedSchedulingHost = forwardedSchedulingHost
forwardErrCh = make(chan error, 1)
go forwardRegionHeartbeatToScheduling(forwardSchedulingStream, server, forwardErrCh)
go forwardRegionHeartbeatToScheduling(rc, forwardSchedulingStream, server, forwardErrCh)
}
schedulingpbReq := &schedulingpb.RegionHeartbeatRequest{
Header: &schedulingpb.RequestHeader{
Expand Down
Loading