diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c8056390f8..98bb4d4ebfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -123,6 +123,7 @@ * [BUGFIX] Querier: Fix stddev+stdvar aggregations to treat Infinity consistently. #9844 * [BUGFIX] Ingester: Chunks could have one unnecessary zero byte at the end. #9844 * [BUGFIX] OTLP receiver: Preserve colons and combine multiple consecutive underscores into one when generating metric names in suffix adding mode (`-distributor.otel-metric-suffixes-enabled`). #10075 +* [BUGFIX] Distributor: Use a boolean to track changes while merging the ReplicaDesc components, rather than comparing the objects directly. #10185 ### Mixin diff --git a/pkg/distributor/ha_tracker.go b/pkg/distributor/ha_tracker.go index 1db18d603c2..154707dee5a 100644 --- a/pkg/distributor/ha_tracker.go +++ b/pkg/distributor/ha_tracker.go @@ -82,27 +82,32 @@ func (r *ReplicaDesc) mergeWithTime(mergeable memberlist.Mergeable) (memberlist. return nil, nil } + changed := false if other.Replica == r.Replica { // Keeping the one with the most recent receivedAt timestamp if other.ReceivedAt > r.ReceivedAt { *r = *other + changed = true } else if r.ReceivedAt == other.ReceivedAt && r.DeletedAt == 0 && other.DeletedAt != 0 { *r = *other + changed = true } } else { // keep the most recent ElectedAt to reach consistency if other.ElectedAt > r.ElectedAt { *r = *other + changed = true } else if other.ElectedAt == r.ElectedAt { // if the timestamps are equal we compare ReceivedAt if other.ReceivedAt > r.ReceivedAt { *r = *other + changed = true } } } // No changes - if *r != *other { + if !changed { return nil, nil } diff --git a/pkg/distributor/ha_tracker_test.go b/pkg/distributor/ha_tracker_test.go index f596e5e4c4e..9438fd5ae3b 100644 --- a/pkg/distributor/ha_tracker_test.go +++ b/pkg/distributor/ha_tracker_test.go @@ -223,6 +223,13 @@ func TestReplicaDescMerge(t *testing.T) { }(), expectedChange: nil, }, + { + name: "Merge should return no change when replica is the same", + rDesc1: firstReplica(), + rDesc2: firstReplica(), + expectedRDesc: firstReplica(), + expectedChange: nil, + }, } for _, tt := range testsMerge {