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

[dbnode] Emit consistencyResultError from fetchTaggedResultAccumulator #3016

Merged
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
11 changes: 8 additions & 3 deletions src/dbnode/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ func IsBadRequestError(err error) bool {

// IsConsistencyResultError determines if the error is a consistency result error.
func IsConsistencyResultError(err error) bool {
_, ok := err.(consistencyResultErr)
return ok
for err != nil {
if _, ok := err.(consistencyResultErr); ok { //nolint:errorlint
return true
}
err = xerrors.InnerError(err)
}
return false
}

// NumResponded returns how many nodes responded for a given error
Expand Down Expand Up @@ -117,8 +122,8 @@ func isHostNotAvailableError(err error) bool {

type consistencyResultError interface {
error
xerrors.ContainedError

InnerError() error
numResponded() int
numSuccess() int
}
Expand Down
10 changes: 8 additions & 2 deletions src/dbnode/client/fetch_tagged_results_accumulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,14 @@ func (accum *fetchTaggedResultAccumulator) accumulatedResult(
doneAccumulating := true
// NB(r): Use new renamed error to keep the underlying error
// (invalid/retryable) type.
err := fmt.Errorf("unable to satisfy consistency requirements: shards=%d, err=%v",
accum.numShardsPending, accum.errors)
enqueued := accum.topoMap.HostsLen()
responded := enqueued
consistencyErr := newConsistencyResultError(accum.consistencyLevel, enqueued, responded,
accum.errors)
err := xerrors.Wrapf(
consistencyErr,
"unable to satisfy consistency requirements: shards=%d, err=%v",
accum.numShardsPending, consistencyErr)
for i := range accum.errors {
if IsBadRequestError(accum.errors[i]) {
err = xerrors.NewInvalidParamsError(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ func (tm testFetchStateWorkflow) run() fetchTaggedResultAccumulator {
}
assert.Equal(tm.t, s.expectedDone, done, fmt.Sprintf("i=%d, step=%+v", i, s))
assert.Equal(tm.t, s.expectedErr, err != nil, fmt.Sprintf("i=%d, step=%+v, err=%v", i, s, err))
if err != nil {
assert.True(tm.t, IsConsistencyResultError(err),
fmt.Sprintf("i=%d, step=%+v, expected consistency result error", i, s))
}
}
return accum
}
Expand Down