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

[StreamConsumerGroup] Fix error checks #146

Merged
merged 1 commit into from
Dec 25, 2023
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
6 changes: 3 additions & 3 deletions pkg/dataplane/streamconsumergroup/statehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (sh *stateHandler) start() error {
// stops on stop()
go func() {
if err := sh.refreshStatePeriodically(); err != nil {
if errors.RootCause(err) == errShardRetention {
if errors.Is(errors.RootCause(err), errShardRetention) {

// signal that the Handler needs to be restarted
sh.logger.ErrorWith("Aborting member", "memberID", sh.member.id)
Expand Down Expand Up @@ -127,7 +127,7 @@ func (sh *stateHandler) refreshStatePeriodically() error {
if err != nil {

// in case of shard retention error we want to signal the member to restart
if errors.RootCause(err) == errShardRetention {
if errors.Is(errors.RootCause(err), errShardRetention) {
sh.logger.WarnWith("Failed getting state on shard retention (requested by member)",
"err", errors.GetErrorStackString(err, 10))
return errors.Wrap(err, "Failed refreshing state by demand")
Expand All @@ -145,7 +145,7 @@ func (sh *stateHandler) refreshStatePeriodically() error {
if err != nil {

// in case of shard retention error we want to signal the member to restart
if errors.RootCause(err) == errShardRetention {
if errors.Is(errors.RootCause(err), errShardRetention) {
sh.logger.WarnWith("Failed getting state on shard retention (periodic refresh)",
"err", errors.GetErrorStackString(err, 10))
return errors.Wrap(err, "Failed refreshing state periodically")
Expand Down
6 changes: 3 additions & 3 deletions pkg/dataplane/streamconsumergroup/streamconsumergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (scg *streamConsumerGroup) setState(modifier stateModifier,

err := common.RetryFunc(context.TODO(), scg.logger, attempts, nil, &backoff, func(attempt int) (bool, error) {
state, stateMtimeNanoSeconds, stateMtimeSeconds, err := scg.getStateFromPersistency()
if err != nil && errors.Is(err, v3ioerrors.ErrNotFound) {
if err != nil && !errors.Is(err, v3ioerrors.ErrNotFound) {
return true, errors.Wrap(err, "Failed getting current state from persistency")
}

Expand All @@ -131,7 +131,7 @@ func (scg *streamConsumerGroup) setState(modifier stateModifier,

modifiedState, err = modifier(state)
if err != nil {
if errors.RootCause(err) == errShardRetention {
if errors.Is(errors.RootCause(err), errShardRetention) {

// if shard retention failed the member needs to be aborted, so we can stop retrying
return false, errors.Wrap(err, "Failed modifying state")
Expand Down Expand Up @@ -273,7 +273,7 @@ func (scg *streamConsumerGroup) getShardLocationFromPersistency(shardID int,

// if the error is that the attribute wasn't found, but the shard was found - seek the shard
// according to the configuration
if errors.Is(err, ErrShardSequenceNumberAttributeNotFound) {
if !errors.Is(err, ErrShardSequenceNumberAttributeNotFound) {
return "", errors.Wrap(err, "Failed to get shard sequenceNumber from item attributes")
}

Expand Down