tsdb: call StableHash as appropriate

labels.Labels.Hash() is not guaranteed to be stable over time.
This commit is contained in:
Bryan Boreham 2023-03-27 18:03:03 +00:00
parent 6009066423
commit cc8eb55a22
3 changed files with 3 additions and 3 deletions

View file

@ -593,7 +593,7 @@ func TestCompaction_CompactWithSplitting(t *testing.T) {
ref := p.At()
require.NoError(t, idxr.Series(ref, &lbls, nil))
require.Equal(t, uint64(shardIndex), lbls.Labels().Hash()%shardCount)
require.Equal(t, uint64(shardIndex), labels.StableHash(lbls.Labels())%shardCount)
// Collect all symbols used by series.
lbls.Labels().Range(func(l labels.Label) {

View file

@ -2495,7 +2495,7 @@ func TestHeadShardedPostings(t *testing.T) {
var lbls labels.ScratchBuilder
require.NoError(t, ir.Series(id, &lbls, nil))
require.Equal(t, shardIndex, lbls.Labels().Hash()%shardCount)
require.Equal(t, shardIndex, labels.StableHash(lbls.Labels())%shardCount)
}
}
}

View file

@ -292,7 +292,7 @@ func TestIndexRW_Postings(t *testing.T) {
var lbls labels.ScratchBuilder
require.NoError(t, ir.Series(id, &lbls, nil))
require.Equal(t, shardIndex, lbls.Labels().Hash()%shardCount)
require.Equal(t, shardIndex, labels.StableHash(lbls.Labels())%shardCount)
}
}
})