Documentation ¶
Index ¶
- Constants
- Variables
- func CheckGCSafePoint(ctx context.Context, pdClient pd.Client, ts uint64) error
- func ClampInt(n, min, max int) int
- func CompareEndKey(a, b []byte) int
- func DefineTLSFlags(flags *pflag.FlagSet)
- func EncloseDBAndTable(database, table string) string
- func EncloseName(name string) string
- func FormatAPIV2Key(key []byte, isEnd bool) []byte
- func IsRetryableError(err error) bool
- func LogEnvVariables()
- func MakeSafePointID() string
- func MarshalBackupMeta(meta *backuppb.BackupMeta) ([]byte, error)
- func MaxInt(x int, xs ...int) int
- func MessageIsNotFoundStorageError(msg string) bool
- func MessageIsPermissionDeniedStorageError(msg string) bool
- func MessageIsRetryableStorageError(msg string) bool
- func MinInt(x int, xs ...int) int
- func MinInt64(x int64, xs ...int64) int64
- func NextPowerOfTwo(i int64) int64
- func ParseKey(format, key string) ([]byte, error)
- func StartServiceSafePointKeeper(ctx context.Context, pdClient pd.Client, sp BRServiceSafePoint) error
- func UnmarshalBackupMeta(data []byte) (*backuppb.BackupMeta, error)
- func UpdateServiceSafePoint(ctx context.Context, pdClient pd.Client, sp BRServiceSafePoint) error
- func WithRetry(ctx context.Context, retryableFunc RetryableFunc, backoffer Backoffer) error
- type BRServiceSafePoint
- type Backoffer
- type KeyRange
- type ProgressPrinter
- type RetryableFunc
- type TLSConfig
- type Worker
- type WorkerPool
- func (pool *WorkerPool) Apply(fn taskFunc)
- func (pool *WorkerPool) ApplyOnErrorGroup(eg *errgroup.Group, fn func() error)
- func (pool *WorkerPool) ApplyWithID(fn identifiedTaskFunc)
- func (pool *WorkerPool) ApplyWithIDInErrorGroup(eg *errgroup.Group, fn func(id uint64) error)
- func (pool *WorkerPool) ApplyWorker() *Worker
- func (pool *WorkerPool) HasWorker() bool
- func (pool *WorkerPool) IdleCount() int
- func (pool *WorkerPool) Limit() int
- func (pool *WorkerPool) RecycleWorker(worker *Worker)
Constants ¶
Variables ¶
var ( APIV2KeyPrefix = [...]byte{'r', 0, 0, 0} APIV2KeyPrefixEnd = [...]byte{'r', 0, 0, 1} APIV2KeyPrefixLen = len(APIV2KeyPrefix) )
Functions ¶
func CheckGCSafePoint ¶
CheckGCSafePoint checks whether the ts is older than GC safepoint. Note: It ignores errors other than exceed GC safepoint.
func CompareEndKey ¶
CompareEndKey compared two keys that BOTH represent the EXCLUSIVE ending of some range. An empty end key is the very end, so an empty key is greater than any other keys. Please note that this function is not applicable if any one argument is not an EXCLUSIVE ending of a range.
func DefineTLSFlags ¶
DefineTLSFlags define flags for tls config
func EncloseDBAndTable ¶
EncloseDBAndTable formats the database and table name in sql.
func FormatAPIV2Key ¶
func IsRetryableError ¶
IsRetryableError returns whether the error is transient (e.g. network connection dropped) or irrecoverable (e.g. user pressing Ctrl+C). This function returns `false` (irrecoverable) if `err == nil`.
If the error is a multierr, returns true only if all suberrors are retryable.
func MakeSafePointID ¶
func MakeSafePointID() string
MakeSafePointID makes a unique safe point ID, for reduce name conflict.
func MarshalBackupMeta ¶
func MarshalBackupMeta(meta *backuppb.BackupMeta) ([]byte, error)
MarshalBackupMeta converts the backupmeta strcture to JSON. Unlike json.Marshal, this function also format some []byte fields for human reading.
func MessageIsNotFoundStorageError ¶
MessageIsNotFoundStorageError checks whether the message returning from TiKV is "NotFound" storage I/O error
func MessageIsPermissionDeniedStorageError ¶
MessageIsPermissionDeniedStorageError checks whether the message returning from TiKV is "PermissionDenied" storage I/O error
func MessageIsRetryableStorageError ¶
MessageIsRetryableStorageError checks whether the message returning from TiKV is retryable ExternalStorageError.
func NextPowerOfTwo ¶
NextPowerOfTwo returns the smallest power of two greater than or equal to `i` Caller should guarantee that i > 0 and the return value is not overflow.
func StartServiceSafePointKeeper ¶
func StartServiceSafePointKeeper( ctx context.Context, pdClient pd.Client, sp BRServiceSafePoint, ) error
StartServiceSafePointKeeper will run UpdateServiceSafePoint periodicity hence keeping service safepoint won't lose.
func UnmarshalBackupMeta ¶
func UnmarshalBackupMeta(data []byte) (*backuppb.BackupMeta, error)
UnmarshalBackupMeta converts the prettied JSON format of backupmeta (made by MarshalBackupMeta) back to the go structure.
func UpdateServiceSafePoint ¶
updateServiceSafePoint register BackupTS to PD, to lock down BackupTS as safePoint with TTL seconds.
Types ¶
type BRServiceSafePoint ¶
BRServiceSafePoint is metadata of service safe point from a BR 'instance'.
func (BRServiceSafePoint) MarshalLogObject ¶
func (sp BRServiceSafePoint) MarshalLogObject(encoder zapcore.ObjectEncoder) error
MarshalLogObject implements zapcore.ObjectMarshaler.
type Backoffer ¶
type Backoffer interface { // NextBackoff returns a duration to wait before retrying again NextBackoff(err error) time.Duration // Attempt returns the remain attempt times Attempt() int }
Backoffer implements a backoff policy for retrying operations.
func NewBackoffer ¶
NewBackoffer creates a new controller regulating a truncated exponential backoff.
func NewChecksumBackoffer ¶
func NewChecksumBackoffer() Backoffer
func NewDownloadSSTBackoffer ¶
func NewDownloadSSTBackoffer() Backoffer
func NewImportSSTBackoffer ¶
func NewImportSSTBackoffer() Backoffer
func NewPDReqBackoffer ¶
func NewPDReqBackoffer() Backoffer
type KeyRange ¶
func ConvertBackupConfigKeyRange ¶
func ConvertBackupConfigKeyRange(startKey, endKey []byte, srcAPIVer, dstAPIVer kvrpcpb.APIVersion) *KeyRange
ConvertBackupConfigKeyRange do conversion between formated APIVersion key and backupmeta key for example, backup apiv1 -> apiv2, add `r` prefix and `s` for empty end key. apiv2 -> apiv1, remove first byte.
func EncodeKeyRange ¶
func FormatAPIV2KeyRange ¶
FormatAPIV2KeyRange convert user key to APIV2 format.
type ProgressPrinter ¶
type ProgressPrinter struct {
// contains filtered or unexported fields
}
ProgressPrinter prints a progress bar.
func NewProgressPrinter ¶
func NewProgressPrinter( name string, total int64, redirectLog bool, ) *ProgressPrinter
NewProgressPrinter returns a new progress printer.
func StartProgress ¶
func StartProgress( ctx context.Context, name string, total int64, redirectLog bool, log logFunc, ) *ProgressPrinter
StartProgress starts progress bar.
func (*ProgressPrinter) Close ¶
func (pp *ProgressPrinter) Close()
Close closes the current progress bar.
func (*ProgressPrinter) Inc ¶
func (pp *ProgressPrinter) Inc()
Inc increases the current progress bar.
type TLSConfig ¶
type TLSConfig struct { CA string `json:"ca" toml:"ca"` Cert string `json:"cert" toml:"cert"` Key string `json:"key" toml:"key"` }
TLSConfig is the common configuration for TLS connection.
func (*TLSConfig) ParseFromFlags ¶
ParseFromFlags parses the TLS config from the flag set.
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool contains a pool of workers.
func NewWorkerPool ¶
func NewWorkerPool(limit uint, name string) *WorkerPool
NewWorkerPool returns a WorkPool.
func (*WorkerPool) ApplyOnErrorGroup ¶
func (pool *WorkerPool) ApplyOnErrorGroup(eg *errgroup.Group, fn func() error)
ApplyOnErrorGroup executes a task in an errorgroup.
func (*WorkerPool) ApplyWithID ¶
func (pool *WorkerPool) ApplyWithID(fn identifiedTaskFunc)
ApplyWithID execute a task and provides it with the worker ID.
func (*WorkerPool) ApplyWithIDInErrorGroup ¶
func (pool *WorkerPool) ApplyWithIDInErrorGroup(eg *errgroup.Group, fn func(id uint64) error)
ApplyWithIDInErrorGroup executes a task in an errorgroup and provides it with the worker ID.
func (*WorkerPool) ApplyWorker ¶
func (pool *WorkerPool) ApplyWorker() *Worker
ApplyWorker apply a worker.
func (*WorkerPool) HasWorker ¶
func (pool *WorkerPool) HasWorker() bool
HasWorker checks if the pool has unallocated workers.
func (*WorkerPool) IdleCount ¶
func (pool *WorkerPool) IdleCount() int
IdleCount counts how many idle workers in the pool.
func (*WorkerPool) RecycleWorker ¶
func (pool *WorkerPool) RecycleWorker(worker *Worker)
RecycleWorker recycle a worker.