Skip to content

Commit 7769647

Browse files
authored
Fix nil pointer exception in GenerateTokens (#6768)
* Fix nil pointer exception in GenerateTokens Signed-off-by: Justin Jung <[email protected]> * Changelog Signed-off-by: Justin Jung <[email protected]> --------- Signed-off-by: Justin Jung <[email protected]>
1 parent 44de94b commit 7769647

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* [BUGFIX] Ingester: Avoid resharding for query when restart readonly ingesters. #6642
4646
* [BUGFIX] Query Frontend: Fix query frontend per `user` metrics clean up. #6698
4747
* [BUGFIX] Add `__markers__` tenant ID validation. #6761
48+
* [BUGFIX] Ring: Fix nil pointer exception when token is shared. #6768
4849

4950
## 1.19.0 2025-02-27
5051

pkg/ring/token_generator.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ func (g *MinimizeSpreadTokenGenerator) GenerateTokens(ring *Desc, id, zone strin
136136
for i := 1; i <= len(zonalTokens); i++ {
137137
index := i % len(zonalTokens)
138138
if tokenInstanceId, ok := usedTokens[zonalTokens[index]]; ok && tokenInstanceId != id {
139-
instanceDistance := tokensPerInstanceWithDistance[tokenInstanceId]
139+
instanceDistance, ok := tokensPerInstanceWithDistance[tokenInstanceId]
140+
if !ok {
141+
continue // Same token is shared to an ingester in different zone, skip
142+
}
143+
140144
instanceDistance.tokens = append(instanceDistance.tokens, &tokenDistanceEntry{
141145
token: zonalTokens[index],
142146
prev: zonalTokens[i-1],

0 commit comments

Comments
 (0)