Skip to content

Commit

Permalink
mark ErrTooOldSample as SampleConflict error
Browse files Browse the repository at this point in the history
Fixes thanos-io#6040

Signed-off-by: Jan Jansen <jan.jansen@gdata.de>
  • Loading branch information
farodin91 authored and Nathaniel Graham committed Apr 17, 2023
1 parent 6320c21 commit 7d4f3c2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -21,6 +21,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re

### Fixed
- [#5995] (https://github.com/thanos-io/thanos/pull/5993) Sidecar: Loads the TLS certificate during startup.
- [#6044](https://github.com/thanos-io/thanos/pull/6044) Receive: mark ouf of window errors as conflict, if out-of-window samples ingestion is activated

## [v0.30.0](https://github.com/thanos-io/thanos/tree/release-0.30) - in progress.

Expand Down
3 changes: 2 additions & 1 deletion pkg/receive/handler.go
Expand Up @@ -865,7 +865,8 @@ func isConflict(err error) bool {
func isSampleConflictErr(err error) bool {
return err == storage.ErrDuplicateSampleForTimestamp ||
err == storage.ErrOutOfOrderSample ||
err == storage.ErrOutOfBounds
err == storage.ErrOutOfBounds ||
err == storage.ErrTooOldSample
}

// isExemplarConflictErr returns whether or not the given error represents
Expand Down
18 changes: 18 additions & 0 deletions pkg/receive/handler_test.go
Expand Up @@ -211,6 +211,7 @@ func newTestHandlerHashring(appendables []*fakeAppendable, replicationFactor uin
func testReceiveQuorum(t *testing.T, hashringAlgo HashringAlgorithm, withConsistencyDelay bool) {
appenderErrFn := func() error { return errors.New("failed to get appender") }
conflictErrFn := func() error { return storage.ErrOutOfBounds }
tooOldSampleErrFn := func() error { return storage.ErrTooOldSample }
commitErrFn := func() error { return errors.New("failed to commit") }
wreq := &prompb.WriteRequest{
Timeseries: makeSeriesWithValues(50),
Expand Down Expand Up @@ -392,6 +393,23 @@ func testReceiveQuorum(t *testing.T, hashringAlgo HashringAlgorithm, withConsist
},
},
},
{
name: "size 3 conflict with replication and error is ErrTooOldSample",
status: http.StatusConflict,
replicationFactor: 3,
wreq: wreq,
appendables: []*fakeAppendable{
{
appender: newFakeAppender(tooOldSampleErrFn, nil, nil),
},
{
appender: newFakeAppender(tooOldSampleErrFn, nil, nil),
},
{
appender: newFakeAppender(tooOldSampleErrFn, nil, nil),
},
},
},
{
name: "size 3 with replication and one faulty",
status: http.StatusOK,
Expand Down

0 comments on commit 7d4f3c2

Please sign in to comment.