retry

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
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

View Source
var CommitMaxBackoff = 41000

CommitMaxBackoff is max sleep time of the 'commit' command

Functions

func NewBackoffFn

func NewBackoffFn(base, cap, jitter int) func(ctx context.Context) int

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

func NewBackoffer(ctx context.Context, maxSleep int) *Backoffer

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

func (b *Backoffer) Clone() *Backoffer

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

func (b *Backoffer) GetContext() context.Context

GetContext returns the associated context.

func (*Backoffer) String

func (b *Backoffer) String() string

func (*Backoffer) TotalSleep

func (b *Backoffer) TotalSleep() time.Duration

TotalSleep returns the total sleep time of the backoffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL