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

fix leader changed bug #137

Merged
merged 3 commits into from
Jun 13, 2022
Merged

Conversation

MegaByte875
Copy link
Contributor

No description provided.

@MegaByte875 MegaByte875 requested review from veezhang and kqzh June 6, 2022 08:49
if execResp, ok := resp.(*meta.ExecResp); ok {
return execResp.Code
}
return reflect.ValueOf(resp).Elem().Field(0).Interface().(nebula.ErrorCode)
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems puzzling, is there a better way?

if execResp, ok := resp.(*meta.ExecResp); ok {
return execResp.Leader
}
return reflect.ValueOf(resp).Elem().Field(1).Interface().(*nebula.HostAddr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the previous one.

}

for _, space := range spaces {
if contains(nc.Status.Storaged.BalancedSpaces, *space.Id.SpaceID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not check the spaces every time?
Is it possible that the time between the two executions of this function is relatively long?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A balanced space is not needed balance again.

return nil
}
}
log.Info("Balance job in progress")
return &utilerrors.ReconcileError{Msg: fmt.Sprintf("Balance job %d still in progress", jobID)}
}

func (m *metaClient) retryOnError(req interface{}, fn ExecFn) error {
func (m *metaClient) retryOnError(req interface{}, fn Fn) (interface{}, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about ?

type (
    ExecResp interface{
        GetErrorCode() nebula.ErrorCode 
        GetChangedLeader() *nebula.HostAddr
    }
    ExecFn func(req interface{}) (ExecResp, error)
)
func (m *metaClient) retryOnError(req interface{}, fn ExecFn) error {
    ...
}
You can set the `resp` in `ExecFn` to avoid type conversions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's tedious, each method must define a wrapper to implement ExecResp. I prefer using reflect to get the response value.

@wey-gu
Copy link
Contributor

wey-gu commented Jun 7, 2022

@MegaByte875 could I know the behavoir of the bug that this PR is trying to fix, please?

@MegaByte875
Copy link
Contributor Author

@wey-gu Yes, fix the leader change bug.

Copy link
Contributor

@kqzh kqzh left a comment

Choose a reason for hiding this comment

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

LGTM

@kqzh kqzh merged commit fdd9351 into vesoft-inc:master Jun 13, 2022
@MegaByte875 MegaByte875 deleted the reconnect_bug_fix branch July 19, 2022 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants