Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
* [BUGFIX] Experimental Delete Series: Fixed a data race in Purger. #2817
* [BUGFIX] KV: Fixed a bug that triggered a panic due to metrics being registered with the same name but different labels when using a `multi` configured KV client. #2837
* [BUGFIX] Query-frontend: Fix passing HTTP `Host` header if `-frontend.downstream-url` is configured. #2880
* [BUGFIX] Ingester: Improve time-series distribution when `-experimental.distributor.user-subring-size` is enabled. #2887

## 1.2.0 / 2020-07-01

Expand Down
2 changes: 1 addition & 1 deletion pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func (d *Distributor) Push(ctx context.Context, req *client.WriteRequest) (*clie

// Obtain a subring if required
if size := d.limits.SubringSize(userID); size > 0 {
h := client.HashAdd32(client.HashNew32(), userID)
h := client.HashAdd32a(client.HashNew32a(), userID)
subRing, err = d.ingestersRing.Subring(h, size)
if err != nil {
return nil, httpgrpc.Errorf(http.StatusInternalServerError, "unable to create subring: %v", err)
Expand Down
22 changes: 22 additions & 0 deletions pkg/ingester/client/fnv.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,25 @@ func HashAddByte32(h uint32, b byte) uint32 {
h ^= uint32(b)
return h
}

// HashNew32a initializies a new fnv32a hash value.
func HashNew32a() uint32 {
return offset32
}

// HashAdd32a adds a string to a fnv32a hash value, returning the updated hash.
// Note this is the same algorithm as Go stdlib `sum32.Write()`
func HashAdd32a(h uint32, s string) uint32 {
for i := 0; i < len(s); i++ {
h ^= uint32(s[i])
h *= prime32
}
return h
}

// HashAddByte32a adds a byte to a fnv32a hash value, returning the updated hash.
func HashAddByte32a(h uint32, b byte) uint32 {
h ^= uint32(b)
h *= prime32
return h
}