Skip to content

Commit

Permalink
Extra sleep when __consumer_offsets does not exist yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanbergen committed Apr 10, 2015
1 parent c3b50d6 commit 7ce3dcb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,15 @@ func (client *client) getConsumerMetadata(consumerGroup string, retriesRemaining
case ErrConsumerCoordinatorNotAvailable:
Logger.Printf("client/coordinator Coordinator for consumer group %s is not available.\n", consumerGroup)

// This is quite shitty, but this scenario will only happen once per cluster, because the
// __consumer_offsets only has to be created one time.
if client.metadata["__consumer_offsets"] == nil {
if err := client.RefreshMetadata("__consumer_offsets"); err == ErrUnknownTopicOrPartition {
Logger.Printf("client/coordinator The __consumer_offsets topic does not yet exist.\n", consumerGroup)
time.Sleep(2 * time.Second)
}
}

if retriesRemaining > 0 {
Logger.Printf("Retrying after %dms... (%d retries remaining)\n", client.conf.Metadata.Retry.Backoff/time.Millisecond, retriesRemaining)
time.Sleep(client.conf.Metadata.Retry.Backoff)
Expand Down

0 comments on commit 7ce3dcb

Please sign in to comment.