mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-16 00:41:24 +01:00
lib/promscrape: make cluster membership calculations consistent across 32-bit and 64-bit architectures
This commit is contained in:
parent
5277507932
commit
02c0959380
@ -727,8 +727,8 @@ func needSkipScrapeWork(key string, membersCount, replicasCount, memberNum int)
|
|||||||
if membersCount <= 1 {
|
if membersCount <= 1 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
h := int(xxhash.Sum64(bytesutil.ToUnsafeBytes(key)))
|
h := xxhash.Sum64(bytesutil.ToUnsafeBytes(key))
|
||||||
idx := h % membersCount
|
idx := int(h % uint64(membersCount))
|
||||||
if replicasCount < 1 {
|
if replicasCount < 1 {
|
||||||
replicasCount = 1
|
replicasCount = 1
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@ func TestNeedSkipScrapeWork(t *testing.T) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
needSkip := needSkipScrapeWork(key, membersCount, replicationFactor, memberNum)
|
needSkip := needSkipScrapeWork(key, membersCount, replicationFactor, memberNum)
|
||||||
if needSkip != needSkipExpected {
|
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
|
// Disabled clustering
|
||||||
|
Loading…
Reference in New Issue
Block a user