Skip to content

Commit

Permalink
Fix crash bug related to sharding
Browse files Browse the repository at this point in the history
  • Loading branch information
kentquirk committed May 16, 2022
1 parent 744df42 commit d1a8cfa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sharder/deterministic.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ func (d *DeterministicSharder) WhichShard(traceID string) Shard {
portion := math.MaxUint32 / len(d.peers)
index := v / uint32(portion)

// #454 -- index can get out of range if v is close to 0xFFFFFFFF and portion would be non-integral.
// Consider revisiting this with a different sharding mechanism if we rework our scaling behavior.
if index > uint32(len(d.peers)) {
index = 0
}

return d.peers[index]
}

Expand Down

0 comments on commit d1a8cfa

Please sign in to comment.