Skip to content

Commit

Permalink
client: given both retries and errors, prefer retries
Browse files Browse the repository at this point in the history
Now that some errors (e.g. UnknownTopicOrParition) set *both* a retry flag and
an error, we should handle retries first. This is sort-of non-idiomatic in that
`updateMetadata` now returns a non-nil error with a "valid" result, but I think
that's OK.
  • Loading branch information
eapache committed Mar 20, 2015
1 parent 58fb767 commit 45741c4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func (client *client) tryRefreshMetadata(topics []string, retriesRemaining int)
if len(retry) > 0 {
if retriesRemaining <= 0 {
Logger.Println("Some partitions are leaderless, but we're out of retries")
return nil
return err
}
Logger.Printf("Some partitions are leaderless, waiting %dms for election... (%d retries remaining)\n",
client.conf.Metadata.Retry.Backoff/time.Millisecond, retriesRemaining)
Expand Down Expand Up @@ -591,13 +591,9 @@ func (client *client) updateMetadata(data *MetadataResponse) ([]string, error) {
client.cachedPartitionsResults[topic.Name] = partitionCache
}

if err != nil {
return nil, err
}

ret := make([]string, 0, len(toRetry))
for topic := range toRetry {
ret = append(ret, topic)
}
return ret, nil
return ret, err
}

0 comments on commit 45741c4

Please sign in to comment.