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

prevents duplicate log lines from being replayed. closes #3378 #3388

Merged
merged 1 commit into from
Feb 26, 2021
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
3 changes: 3 additions & 0 deletions pkg/ingester/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ func (s *streamIterator) Next() bool {
s.current.Fingerprint = uint64(stream.fp)
s.current.Labels = client.FromLabelsToLabelAdapters(stream.labels)

s.current.To = stream.lastLine.ts
s.current.LastLine = stream.lastLine.content

return true
}

Expand Down
177 changes: 145 additions & 32 deletions pkg/ingester/checkpoint.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/ingester/checkpoint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ message Series {
uint64 fingerprint = 2;
repeated cortex.LabelPair labels = 3 [(gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/cortexproject/cortex/pkg/ingester/client.LabelAdapter"];
repeated Chunk chunks = 4 [(gogoproto.nullable) = false];
// Last timestamp of the last chunk.
google.protobuf.Timestamp to = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
string lastLine = 6;
}
9 changes: 8 additions & 1 deletion pkg/ingester/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ func Test_EncodingCheckpoint(t *testing.T) {
UserID: "fake",
Fingerprint: 123,
Labels: client.FromLabelsToLabelAdapters(ls),
To: time.Unix(10, 0),
LastLine: "lastLine",
Chunks: []Chunk{
{
From: from,
Expand Down Expand Up @@ -275,12 +277,17 @@ func Test_EncodingCheckpoint(t *testing.T) {
outChunks := out.Chunks
out.Chunks = nil

zero := time.Unix(0, 0)

require.Equal(t, true, s.To.Equal(out.To))
s.To = zero
out.To = zero

require.Equal(t, s, out)
require.Equal(t, len(sChunks), len(outChunks))
for i, exp := range sChunks {

got := outChunks[i]
zero := time.Unix(0, 0)
// Issues diffing zero-value time.Locations against nil ones.
// Check/override them individually so that other fields get tested in an extensible manner.
require.Equal(t, true, exp.From.Equal(got.From))
Expand Down
2 changes: 2 additions & 0 deletions pkg/ingester/recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ func (r *ingesterRecoverer) Series(series *Series) error {
}

bytesAdded, entriesAdded, err := stream.setChunks(series.Chunks)
stream.lastLine.ts = series.To
stream.lastLine.content = series.LastLine

if err != nil {
return err
Expand Down
Loading