tiup icon indicating copy to clipboard operation
tiup copied to clipboard

Retry function timeout parameter invalid

Open zdyxry opened this issue 3 years ago • 1 comments

Bug Report

https://github.com/pingcap/tiup/blob/master/pkg/utils/retry.go#L80-L92

        for attemptCount = 0; attemptCount < cfg.Attempts; attemptCount++ {
		if err := doFunc(); err == nil {
			return nil
		}

		// check for timeout
		select {
		case <-timeoutChan:
			return fmt.Errorf("operation timed out after %s", cfg.Timeout)
		default:
			time.Sleep(cfg.Delay)
		}
	}

It looks like the Retry function will always wait for doFunc() to complete and then check the timeout channel.

zdyxry avatar Sep 10 '22 03:09 zdyxry

I'm not sure, are you saying that we should put doFunc() into the default of select sentence? Or could you provide more details about what you did and why you think it's not working as your expected?

AstroProfundis avatar Sep 16 '22 06:09 AstroProfundis