Skip to content

Commit

Permalink
Complementary fix of partition rebalnce issue(wvanbergen#62)
Browse files Browse the repository at this point in the history
This is complementary fix for
wvanbergen#68
(issue: wvanbergen#62), before the
re-implementation (wvanbergen#72) is ready.

In my use case, the message consuming logic is sometimes time consuming,
even with 3 times retry as the fix in pull#68, it's still easy to have
the issue#62. Furhter checking current logic in
consumer_group.go:partitionConsumer(), it may take
as many as cg.config.Offsets.ProcessingTimeout to ReleasePartition
so that the partition can be claimed by new consumer during rebalance.
So just simply set the max retry time same as
cg.config.Offsets.ProcessingTimeout, which is 60s by default.

Verified this the system including this fix with frequent rebalance
operations, the issue does not occur again.
  • Loading branch information
Caihua Yin committed Apr 19, 2016
1 parent 1ff806b commit 8c0e3d5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion consumergroup/consumer_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func (cg *ConsumerGroup) partitionConsumer(topic string, partition int32, messag
default:
}

for maxRetries, tries := 3, 0; tries < maxRetries; tries++ {
for maxRetries, tries := int(cg.config.Offsets.ProcessingTimeout/time.Second), 0; tries < maxRetries; tries++ {
if err := cg.instance.ClaimPartition(topic, partition); err == nil {
break
} else if err == kazoo.ErrPartitionClaimedByOther && tries+1 < maxRetries {
Expand Down

0 comments on commit 8c0e3d5

Please sign in to comment.