mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
lib/promscrape: make cluster membership calculations consistent across 32-bit and 64-bit architectures
This commit is contained in:
parent
a14053ffa0
commit
444fca89f8
@ -727,8 +727,8 @@ func needSkipScrapeWork(key string, membersCount, replicasCount, memberNum int)
|
||||
if membersCount <= 1 {
|
||||
return false
|
||||
}
|
||||
h := int(xxhash.Sum64(bytesutil.ToUnsafeBytes(key)))
|
||||
idx := h % membersCount
|
||||
h := xxhash.Sum64(bytesutil.ToUnsafeBytes(key))
|
||||
idx := int(h % uint64(membersCount))
|
||||
if replicasCount < 1 {
|
||||
replicasCount = 1
|
||||
}
|
||||
|
@ -17,7 +17,8 @@ func TestNeedSkipScrapeWork(t *testing.T) {
|
||||
t.Helper()
|
||||
needSkip := needSkipScrapeWork(key, membersCount, replicationFactor, memberNum)
|
||||
if needSkip != needSkipExpected {
|
||||
t.Fatalf("unexpected needSkipScrapeWork(key=%q, membersCount=%d, replicationFactor=%d, memberNum=%d)", key, membersCount, replicationFactor, memberNum)
|
||||
t.Fatalf("unexpected needSkipScrapeWork(key=%q, membersCount=%d, replicationFactor=%d, memberNum=%d); got %v; want %v",
|
||||
key, membersCount, replicationFactor, memberNum, needSkip, needSkipExpected)
|
||||
}
|
||||
}
|
||||
// Disabled clustering
|
||||
|
Loading…
Reference in New Issue
Block a user