From d40ac19888c694c4d6864df6809c3c2bc6325441 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Tue, 6 Feb 2024 17:32:08 -0700 Subject: [PATCH 1/3] kgo: un-deprecate SaramaHasher and add docs explaining why Closes #669. --- pkg/kgo/partitioner.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/kgo/partitioner.go b/pkg/kgo/partitioner.go index 4cb21896..be0587f2 100644 --- a/pkg/kgo/partitioner.go +++ b/pkg/kgo/partitioner.go @@ -487,9 +487,16 @@ func KafkaHasher(hashFn func([]byte) uint32) PartitionerHasher { } } -// Deprecated: SaramaHasher is not compatible with Sarama's default partitioner -// and only remains to avoid re-keying records for existing users of this API. See -// [SaramaCompatHasher] for a correct partitioner. +// SaramaHasher is a historical misnamed partitioner. This library's original +// implementation of the SaramaHasher was incorrect, if you want an exact +// match for the Sarama partitioner, use the [SaramaCompatHasher]. +// +// This partitioner remains because as it turns out, other ecosystems provide +// a similar partitioner and this partitioner is useful for compatibility. +// +// In particular, using this function with a crc32.ChecksumIEEE hasher makes +// this partitioner match librdkafka's consistent partitioner, or the +// zendesk/ruby-kafka partitioner. func SaramaHasher(hashFn func([]byte) uint32) PartitionerHasher { return func(key []byte, n int) int { p := int(hashFn(key)) % n From cd65d77d05f71ca51d81d247312d0d465fdb76c8 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Tue, 6 Feb 2024 17:41:33 -0700 Subject: [PATCH 2/3] kgo: fix bug Previously, if CommitOffsetsSync was called during a rebalance, and the context being used is canceled while the rebalance was occurring, then the client would deadlock. Internally, committing is blocked if a rebalance is actively happening. There's some complex logic to have, effectively, a cancelable lock if the user wants to not wait for a rebalance to complete while trying to commit offsets. There was a bug, and since the fix is one line, it's easier to see than explain. Closes #668. --- pkg/kgo/consumer_group.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/kgo/consumer_group.go b/pkg/kgo/consumer_group.go index e71fcb52..81832a6e 100644 --- a/pkg/kgo/consumer_group.go +++ b/pkg/kgo/consumer_group.go @@ -2584,6 +2584,7 @@ func (g *groupConsumer) commitOffsetsSync( if err := g.waitJoinSyncMu(ctx); err != nil { onDone(g.cl, kmsg.NewPtrOffsetCommitRequest(), kmsg.NewPtrOffsetCommitResponse(), err) + close(done) return } unblockCommits := func(cl *Client, req *kmsg.OffsetCommitRequest, resp *kmsg.OffsetCommitResponse, err error) { From 20867cdc9564f6372fefd753ad9c5093d6eaacbf Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Tue, 6 Feb 2024 17:47:11 -0700 Subject: [PATCH 3/3] CHANGELOG: note incoming v1.16.1 --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5eccf9e2..a16e2063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +v1.16.1 +=== + +This patch release fixes one bug and un-deprecates SaramaHasher. + +SaramaHasher, while not identical to Sarama's partitioner, actually _is_ +identical to some other partitioners in the Kafka client ecosystem. So, the old +function is now un-deprecated, but the documentation correctly points you to +SaramaCompatHasher and mentions why you may still want to use SaramaHasher. + +For the bug: if you tried using CommitOffsetsSync during a group rebalance, and +you canceled your context while the group was still rebalancing, then +CommitOffsetsSync would enter a deadlock and never return. That has been fixed. + +- [`cd65d77`](https://github.com/twmb/franz-go/commit/cd65d77) kgo: fix bug +- [`d40ac19`](https://github.com/twmb/franz-go/commit/d40ac19) kgo: un-deprecate SaramaHasher and add docs explaining why + v1.16.0 ===