-
Notifications
You must be signed in to change notification settings - Fork 2
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
chore(*): use proper retry #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One note, babylon retry library have hardcoded errors which should/should not be retries:
var unrecoverableErrors = []error{
btclctypes.ErrHeaderParentDoesNotExist,
btclctypes.ErrChainWithNotEnoughWork,
btclctypes.ErrInvalidHeader,
btcctypes.ErrProvidedHeaderDoesNotHaveAncestor,
btcctypes.ErrInvalidHeader,
btcctypes.ErrNoCheckpointsForPreviousEpoch,
btcctypes.ErrInvalidCheckpointProof,
checkpointingtypes.ErrBlsPrivKeyDoesNotExist,
// TODO Add more errors here
}
// expectedErrors is a list of errors which can safely be ignored and should not be retried.
var expectedErrors = []error{
btcctypes.ErrDuplicatedSubmission,
btcctypes.ErrInvalidHeader,
// TODO Add more errors here
}
could you double check that this errors are relevant in this context ?
}); err != nil { | ||
}, | ||
retry.Delay(m.ComCfg.RetrySleepTime), | ||
retry.MaxDelay(m.ComCfg.MaxRetrySleepTime), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say we need to pass attempts config to every method, it would pretty wierd that some methods do not respect config value.
opts = append(opts, opt) | ||
|
||
err := retry.Do(retryableFunc, opts...) | ||
if containsErr(expectedErrors, err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we check the expected errors twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RafilxTenfen when retryif
returns false, that means that Do
is returning an error, we want to check if this error is expected
and ignore it (return nil), as we don't want to keep retrying on expected
errors or unrecoverable
but in that case we do return an error. This is matching behavior of retry implementation in Babylon repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, thanks for explaining
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, few minor comments.
One note for the future, for now it is fine to have this global list of errors, to not change behaviour, but ultimately this errors (unrecorevable/expected) should be set at call site by each caller. Then we know what call can return, what error and each caller knows what to do with each error. Maybe you could create task to get rid of those global error lists ?
blockHash, err = c.GetBestBlockHash() | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
}); err != nil { | ||
}, | ||
retry.Delay(c.retrySleepTime), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are those those options ever set in btclient
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed in f7c96e3
btccParamsRes, err = babylonClient.BTCCheckpointParams() | ||
return err | ||
}) | ||
}, | ||
retry.Delay(retrySleepTime), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say that, given max-attempts
is in common potion of the config it should probably set in every program, otherwise we risk seeing some wierd behaviour only to learn some toold respect this config option and some does not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed added it in f7c96e3
Replaces usage of
retry.do
from babylon withavast/retry-go
References issue