From 3f472330790204e4d09b7a4e087be3ff0dc04eff Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Tue, 24 Sep 2024 14:07:03 +0200 Subject: [PATCH] fix(kafka): Fixes partition selection in distributors (#14242) --- pkg/distributor/distributor.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index 08fba483ec9b..3ad586f3e596 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -901,12 +901,11 @@ func (d *Distributor) sendStreamToKafka(ctx context.Context, stream KeyedStream, if len(stream.Stream.Entries) == 0 { return nil } - /* partitionID, err := d.partitionRing.PartitionRing().ActivePartitionForKey(stream.HashKey) - if err != nil { - d.kafkaAppends.WithLabelValues("kafka", "fail").Inc() - return fmt.Errorf("failed to find active partition for stream: %w", err) - }*/ - partitionID := int32(0) + partitionID, err := d.partitionRing.PartitionRing().ActivePartitionForKey(stream.HashKey) + if err != nil { + d.kafkaAppends.WithLabelValues("kafka", "fail").Inc() + return fmt.Errorf("failed to find active partition for stream: %w", err) + } startTime := time.Now()