Skip to content

Commit

Permalink
Receiver: Handle storage exemplar multi-error (#5502)
Browse files Browse the repository at this point in the history
* Handle exemplar store errors as conflict

Signed-off-by: Matej Gera <matejgera@gmail.com>

* Adjust tests

Signed-off-by: Matej Gera <matejgera@gmail.com>

* Update CHANGELOG

Signed-off-by: Matej Gera <matejgera@gmail.com>
  • Loading branch information
matej-g committed Jul 14, 2022
1 parent 1e64191 commit 9b6903b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#5453](https://github.com/thanos-io/thanos/pull/5453) Compact: Skip erroneous empty non `*AggrChunk` chunks during 1h downsampling of 5m resolution blocks.

### Fixed
- [#5502](https://github.com/thanos-io/thanos/pull/5502) Receive: Handle exemplar storage errors as conflict error.

### Added

Expand Down
3 changes: 3 additions & 0 deletions pkg/receive/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,9 @@ func isConflict(err error) bool {
err == storage.ErrDuplicateSampleForTimestamp ||
err == storage.ErrOutOfOrderSample ||
err == storage.ErrOutOfBounds ||
err == storage.ErrDuplicateExemplar ||
err == storage.ErrOutOfOrderExemplar ||
err == storage.ErrExemplarLabelLength ||
status.Code(err) == codes.AlreadyExists
}

Expand Down
23 changes: 23 additions & 0 deletions pkg/receive/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ func TestDetermineWriteErrorCause(t *testing.T) {
threshold: 1,
exp: errConflict,
},
{
name: "matching multierror (exemplar error)",
err: errutil.NonNilMultiError([]error{
storage.ErrExemplarLabelLength,
errors.New("foo"),
errors.New("bar"),
}),
threshold: 1,
exp: errConflict,
},
{
name: "matching but below threshold multierror",
err: errutil.NonNilMultiError([]error{
Expand Down Expand Up @@ -139,6 +149,19 @@ func TestDetermineWriteErrorCause(t *testing.T) {
threshold: 2,
exp: errNotReady,
},
{
name: "matching multierror many, one above threshold (exemplar error)",
err: errutil.NonNilMultiError([]error{
tsdb.ErrNotReady,
tsdb.ErrNotReady,
storage.ErrDuplicateExemplar,
storage.ErrDuplicateSampleForTimestamp,
storage.ErrExemplarLabelLength,
errors.New("foo"),
}),
threshold: 2,
exp: errConflict,
},
{
name: "matching multierror many, both above threshold, conflict have precedence",
err: errutil.NonNilMultiError([]error{
Expand Down

0 comments on commit 9b6903b

Please sign in to comment.