Skip to content

Commit

Permalink
Merge "[FAB-7436] Log err during retry process"
Browse files Browse the repository at this point in the history
  • Loading branch information
kchristidis authored and Gerrit Code Review committed Dec 14, 2017
2 parents 3e9b686 + 30234be commit 2b428bf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions orderer/consensus/kafka/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (rp *retryProcess) retry() error {
return nil
}

func (rp *retryProcess) try(interval, total time.Duration) error {
func (rp *retryProcess) try(interval, total time.Duration) (err error) {
// Configuration validation will not allow non-positive ticker values
// (which would result in panic). The path below is for those test cases
// when we cannot avoid the creation of a retriable process but we wish
Expand All @@ -52,15 +52,15 @@ func (rp *retryProcess) try(interval, total time.Duration) error {
return fmt.Errorf("illegal value")
}

var err error

// If initial operation is successful, we don't bother start retry process
logger.Debugf("[channel: %s] "+rp.msg, rp.channel.topic())
if err := rp.fn(); err == nil {
if err = rp.fn(); err == nil {
logger.Debugf("[channel: %s] Error is nil, breaking the retry loop", rp.channel.topic())
return err
return
}

logger.Debugf("[channel: %s] Initial attempt failed = %s", rp.channel.topic(), err)

tickInterval := time.NewTicker(interval)
tickTotal := time.NewTicker(total)
defer tickTotal.Stop()
Expand All @@ -74,13 +74,15 @@ func (rp *retryProcess) try(interval, total time.Duration) error {
logger.Warning(exitErr.Error()) // Log it at the warning level
return exitErr
case <-tickTotal.C:
return err
return
case <-tickInterval.C:
logger.Debugf("[channel: %s] "+rp.msg, rp.channel.topic())
if err = rp.fn(); err == nil {
logger.Debugf("[channel: %s] Error is nil, breaking the retry loop", rp.channel.topic())
return err
return
}

logger.Debugf("[channel: %s] Need to retry because process failed = %s", rp.channel.topic(), err)
}
}
}

0 comments on commit 2b428bf

Please sign in to comment.