Documentation ¶
Index ¶
Constants ¶
const ( // NoJitter makes the backoff sequence strict exponential. NoJitter = 1 + iota // FullJitter applies random factors to strict exponential. FullJitter // EqualJitter is also randomized, but prevents very short sleeps. EqualJitter // DecorrJitter increases the maximum jitter based on the last random value. DecorrJitter )
const ( CopBuildTaskMaxBackoff = 5000 TsoMaxBackoff = 15000 ScannerNextMaxBackoff = 20000 BatchGetMaxBackoff = 20000 CopNextMaxBackoff = 20000 GetMaxBackoff = 20000 PrewriteMaxBackoff = 20000 CleanupMaxBackoff = 20000 GcOneRegionMaxBackoff = 20000 GcResolveLockMaxBackoff = 100000 DeleteRangeOneRegionMaxBackoff = 100000 RawkvMaxBackoff = 20000 SplitRegionBackoff = 20000 )
Maximum total sleep time(in ms) for kv/cop commands.
Variables ¶
var CommitMaxBackoff = 41000
CommitMaxBackoff is max sleep time of the 'commit' command
Functions ¶
func NewBackoffFn ¶
NewBackoffFn creates a backoff func which implements exponential backoff with optional jitters. See http://www.awsarchitectureblog.com/2015/03/backoff.html
Types ¶
type BackoffType ¶
type BackoffType int
BackoffType is the retryable error type.
const ( BoTiKVRPC BackoffType = iota BoTxnLock BoTxnLockFast BoPDRPC BoRegionMiss BoUpdateLeader BoServerBusy )
Back off types.
func (BackoffType) String ¶
func (t BackoffType) String() string
type Backoffer ¶
type Backoffer struct {
// contains filtered or unexported fields
}
Backoffer is a utility for retrying queries.
func NewBackoffer ¶
NewBackoffer creates a Backoffer with maximum sleep time(in ms).
func (*Backoffer) Backoff ¶
func (b *Backoffer) Backoff(typ BackoffType, err error) error
Backoff sleeps a while base on the BackoffType and records the error message. It returns a retryable error if total sleep time exceeds maxSleep.
func (*Backoffer) Clone ¶
Clone creates a new Backoffer which keeps current Backoffer's sleep time and errors, and shares current Backoffer's context.
func (*Backoffer) Fork ¶
func (b *Backoffer) Fork() (*Backoffer, context.CancelFunc)
Fork creates a new Backoffer which keeps current Backoffer's sleep time and errors, and holds a child context of current Backoffer's context.
func (*Backoffer) GetContext ¶
GetContext returns the associated context.
func (*Backoffer) TotalSleep ¶
TotalSleep returns the total sleep time of the backoffer.