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

Tso client is not ready after create PD client #8962

Open
okJiang opened this issue Dec 31, 2024 · 1 comment · May be fixed by #8963
Open

Tso client is not ready after create PD client #8962

okJiang opened this issue Dec 31, 2024 · 1 comment · May be fixed by #8963
Assignees
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/major type/bug The issue is confirmed as a bug.

Comments

@okJiang
Copy link
Member

okJiang commented Dec 31, 2024

Enhancement Task

If getClusterInfo fails due to the network problem, the tso client will not be initiated. In this way, if the caller calls tso related API, like GetMinTS(), it will report tso client is nil error.

if err := c.checkServiceModeChanged(); err != nil {
log.Warn("[pd] failed to check service mode and will check later", zap.Error(err))
}

func (c *pdServiceDiscovery) checkServiceModeChanged() error {
leaderURL := c.getLeaderURL()
if len(leaderURL) == 0 {
return errors.New("no leader found")
}
clusterInfo, err := c.getClusterInfo(c.ctx, leaderURL, c.option.Timeout)
if err != nil {
if strings.Contains(err.Error(), "Unimplemented") {
// If the method is not supported, we set it to pd mode.
// TODO: it's a hack way to solve the compatibility issue.
// we need to remove this after all maintained version supports the method.
if c.serviceModeUpdateCb != nil {
c.serviceModeUpdateCb(pdpb.ServiceMode_PD_SVC_MODE)
}
return nil
}
return err
}
if clusterInfo == nil || len(clusterInfo.ServiceModes) == 0 {
return errors.WithStack(errs.ErrNoServiceModeReturned)
}
if c.serviceModeUpdateCb != nil {
c.serviceModeUpdateCb(clusterInfo.ServiceModes[0])
}
return nil
}

We can apply retry to this function.

@okJiang okJiang added the type/bug The issue is confirmed as a bug. label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant