Skip to content

Commit 0c3eb68

Browse files
authored
Clean-up Badger's trace-not-found check (#2481)
1 parent 37eaced commit 0c3eb68

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: plugin/storage/badger/spanstore/read_write_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func TestFindNothing(t *testing.T) {
303303

304304
trs, err := sr.FindTraces(context.Background(), params)
305305
assert.NoError(t, err)
306-
assert.Equal(t, 0, len(trs))
306+
assert.Len(t, trs, 0)
307307

308308
tr, err := sr.GetTrace(context.Background(), model.TraceID{High: 0, Low: 0})
309309
assert.Equal(t, spanstore.ErrTraceNotFound, err)

Diff for: plugin/storage/badger/spanstore/reader.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ var (
5454

5555
// ErrNotSupported during development, don't support every option - yet
5656
ErrNotSupported = errors.New("this query parameter is not supported yet")
57+
58+
// ErrInternalConsistencyError indicates internal data consistency issue
59+
ErrInternalConsistencyError = errors.New("internal data consistency issue")
5760
)
5861

5962
const (
@@ -160,11 +163,14 @@ func (r *TraceReader) GetTrace(ctx context.Context, traceID model.TraceID) (*mod
160163
if err != nil {
161164
return nil, err
162165
}
166+
if len(traces) == 0 {
167+
return nil, spanstore.ErrTraceNotFound
168+
}
163169
if len(traces) == 1 {
164170
return traces[0], nil
165171
}
166172

167-
return nil, spanstore.ErrTraceNotFound
173+
return nil, ErrInternalConsistencyError
168174
}
169175

170176
// scanTimeRange returns all the Traces found between startTs and endTs

0 commit comments

Comments
 (0)