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

Parallell.PutValue fails if one router fails but all other succeed #55

Open
ajnavarro opened this issue Jul 6, 2022 · 0 comments
Open
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@ajnavarro
Copy link
Member

We can see here:

// PutValue puts the given key to all sub-routers in parallel. It succeeds as
// long as putting to at least one sub-router succeeds, but it waits for all
// puts to terminate.

that the Parallell.PutValue only fails if none of the routers were able to set the value.

But the logic is wrong here:

var (
errs []error
success bool
)
for _, err := range results {
switch err {
case nil:
// at least one router supports this.
success = true
case routing.ErrNotSupported:
default:
errs = append(errs, err)
}
}
switch len(errs) {
case 0:
if success {
// No errors and at least one router succeeded.
return nil
}
// No routers supported this operation.
return routing.ErrNotSupported
case 1:
return errs[0]
default:
return &multierror.Error{Errors: errs}
}
}

success is only checked if there are no errors, making PutValue fails even if just one router fails.

@ajnavarro ajnavarro added the kind/bug A bug in existing code (including security flaws) label Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

No branches or pull requests

1 participant