Skip to content

Commit b3440e4

Browse files
authored
Add limit time for gossip on ring (#4750)
Signed-off-by: Daniel Blando <[email protected]>
1 parent e34f5e8 commit b3440e4

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
* [BUGFIX] Distributor: Fix race condition on `/series` introduced by #4683. #4716
4141
* [BUGFIX] Ruler: Fixed leaking notifiers after users are removed #4718
4242
* [BUGFIX] Distributor: Fix a memory leak in distributor due to the cluster label. #4739
43+
* [BUGFIX] Memberlist: Avoid clock skew by limiting the timestamp accepted on gossip. #
4344
* [ENHANCEMENT] Compactor: uploading blocks no compaction marks to the global location and introduce a new metric #4729
4445
* `cortex_bucket_blocks_marked_for_no_compaction_count`: Total number of blocks marked for no compaction in the bucket.
4546
* [ENHANCEMENT] Querier: Reduce the number of series that are kept in memory while streaming from ingesters. #4745

pkg/ring/merge_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ func TestMerge(t *testing.T) {
128128
}
129129
}
130130

131+
futureRing := func() *Desc {
132+
return &Desc{
133+
Ingesters: map[string]InstanceDesc{
134+
"Ing 1": {Addr: "addr1", Timestamp: time.Now().Add(31 * time.Minute).Unix(), State: ACTIVE, Tokens: []uint32{30, 40, 50}},
135+
},
136+
}
137+
}
138+
131139
expectedFirstSecondThirdFourthMerge := func() *Desc {
132140
return &Desc{
133141
Ingesters: map[string]InstanceDesc{
@@ -181,6 +189,12 @@ func TestMerge(t *testing.T) {
181189
},
182190
}, ch)
183191
}
192+
193+
{
194+
out, err := firstRing().Merge(futureRing(), false)
195+
assert.Empty(t, out)
196+
assert.ErrorContains(t, err, "ingester Ing 1 timestamp in the future")
197+
}
184198
}
185199

186200
func TestTokensTakeover(t *testing.T) {

pkg/ring/model.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ func (d *Desc) mergeWithTime(mergeable memberlist.Mergeable, localCAS bool, now
209209
var updated []string
210210
tokensChanged := false
211211

212+
maxFutureLimit := now.Add(30 * time.Minute).Unix()
212213
for name, oing := range otherIngesterMap {
214+
if oing.Timestamp > maxFutureLimit {
215+
return nil, fmt.Errorf("ingester %s timestamp in the future, expected max of %d, got %d", name, maxFutureLimit, oing.Timestamp)
216+
}
217+
213218
ting := thisIngesterMap[name]
214219
// ting.Timestamp will be 0, if there was no such ingester in our version
215220
if oing.Timestamp > ting.Timestamp {

0 commit comments

Comments
 (0)