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

Clean-up Badger's trace-not-found check #2481

Merged
merged 2 commits into from
Sep 16, 2020
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
2 changes: 1 addition & 1 deletion plugin/storage/badger/spanstore/read_write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func TestFindNothing(t *testing.T) {

trs, err := sr.FindTraces(context.Background(), params)
assert.NoError(t, err)
assert.Equal(t, 0, len(trs))
assert.Len(t, trs, 0)

tr, err := sr.GetTrace(context.Background(), model.TraceID{High: 0, Low: 0})
assert.Equal(t, spanstore.ErrTraceNotFound, err)
Expand Down
8 changes: 7 additions & 1 deletion plugin/storage/badger/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ var (

// ErrNotSupported during development, don't support every option - yet
ErrNotSupported = errors.New("this query parameter is not supported yet")

// ErrInternalConsistencyError indicates internal data consistency issue
ErrInternalConsistencyError = errors.New("internal data consistency issue")
)

const (
Expand Down Expand Up @@ -160,11 +163,14 @@ func (r *TraceReader) GetTrace(ctx context.Context, traceID model.TraceID) (*mod
if err != nil {
return nil, err
}
if len(traces) == 0 {
return nil, spanstore.ErrTraceNotFound
}
if len(traces) == 1 {
return traces[0], nil
}

return nil, spanstore.ErrTraceNotFound
return nil, ErrInternalConsistencyError
}

// scanTimeRange returns all the Traces found between startTs and endTs
Expand Down