retry

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Stable represents fixed time wait retry policy, every retry should wait a fixed time
	Stable backoffStrategy = iota + 1
	// LinearIncrease represents increase time wait retry policy, every retry should wait more time depends on increasing retry times
	LinearIncrease
)

Variables

View Source
var (
	// UnsupportedDDLMsgs list the error messages of some unsupported DDL in TiDB
	UnsupportedDDLMsgs = []string{
		"can't drop column with index",
		"unsupported add column",
		"unsupported modify column",
		"unsupported modify charset",
		"unsupported modify collate",
		"unsupported drop integer primary key",
		"Unsupported collation",
		"Invalid default value for",
	}

	// UnsupportedDMLMsgs list the error messages of some un-recoverable DML, which is used in task auto recovery
	UnsupportedDMLMsgs = []string{
		"Error 1062: Duplicate entry",
		"Error 1406: Data too long for column",
	}

	// ParseRelayLogErrMsgs list the error messages of some un-recoverable relay log parsing error, which is used in task auto recovery.
	ParseRelayLogErrMsgs = []string{
		"binlog checksum mismatch, data may be corrupted",
		"get event err EOF",
	}

	// UnresumableErrCodes is a set of unresumeable err codes.
	UnresumableErrCodes = map[int32]struct{}{
		int32(terror.ErrSyncUnitDDLWrongSequence.Code()): {},
		int32(terror.ErrSyncerShardDDLConflict.Code()):   {},
	}
)

Functions

func IsConnectionError added in v1.0.2

func IsConnectionError(err error) bool

IsConnectionError tells whether this error should reconnect to Database

Types

type FiniteRetryStrategy

type FiniteRetryStrategy struct {
}

FiniteRetryStrategy will retry `RetryCount` times when failed to operate DB.

func (*FiniteRetryStrategy) Apply

func (*FiniteRetryStrategy) Apply(ctx *tcontext.Context, params Params,
	operateFn func(*tcontext.Context) (interface{}, error)) (ret interface{}, i int, err error)

Apply for FiniteRetryStrategy, it wait `FirstRetryDuration` before it starts first retry, and then rest of retries wait time depends on BackoffStrategy.

type Params

type Params struct {
	RetryCount         int
	FirstRetryDuration time.Duration

	BackoffStrategy backoffStrategy

	// IsRetryableFn tells whether we should retry when operateFn failed
	// params: (number of retry, error of operation)
	// return: (bool)
	//   1. true: means operateFn can be retried
	//   2. false: means operateFn cannot retry after receive this error
	IsRetryableFn func(int, error) bool
}

Params define parameters for Apply it's a parameters union set of all implements which implement Apply

type Strategy

type Strategy interface {

	// Apply define retry strategy
	// params: (retry parameters for this strategy, a normal operation)
	// return: (result of operation, number of retry, error of operation)
	Apply(ctx *tcontext.Context,
		params Params,

		operateFn func(*tcontext.Context) (interface{}, error),
	) (interface{}, int, error)
}

Strategy define different kind of retry strategy

Jump to

Keyboard shortcuts

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