Documentation ¶
Index ¶
- Constants
- func ArchiveSize(meta *backuppb.BackupMeta) uint64
- 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 EncloseDBAndTable(database, table string) string
- func EncloseName(name string) string
- func GetSysDBName(tempDB model.CIStr) (string, bool)
- func IsSysDB(dbLowerName string) bool
- func LoadBackupTables(ctx context.Context, reader *metautil.MetaReader) (map[string]*Database, error)
- 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 NeedAutoID(tblInfo *model.TableInfo) bool
- func NextPowerOfTwo(i int64) int64
- func ParseKey(format, key string) ([]byte, error)
- func StartDynamicPProfListener(tls *tidbutils.TLS)
- func StartPProfListener(statusAddr string, wrapper *tidbutils.TLS) error
- func StartServiceSafePointKeeper(ctx context.Context, pdClient pd.Client, sp BRServiceSafePoint) error
- func TemporaryDBName(db string) model.CIStr
- func UnmarshalBackupMeta(data []byte) (*backuppb.BackupMeta, error)
- func WithRetry(ctx context.Context, retryableFunc RetryableFunc, backoffer Backoffer) error
- type BRServiceSafePoint
- type Backoffer
- type BytesBuffer
- type Database
- type ProgressPrinter
- type RetryableFunc
- 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) RecycleWorker(worker *Worker)
Constants ¶
const (
// DefaultBRGCSafePointTTL means PD keep safePoint limit at least 5min.
DefaultBRGCSafePointTTL = 5 * 60
)
Variables ¶
This section is empty.
Functions ¶
func ArchiveSize ¶
func ArchiveSize(meta *backuppb.BackupMeta) uint64
ArchiveSize returns the total size of the backup archive.
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 EncloseDBAndTable ¶
EncloseDBAndTable formats the database and table name in sql.
func GetSysDBName ¶
GetSysDBName get the original name of system DB
func IsSysDB ¶
IsSysDB tests whether the database is system DB. Currently, the only system DB is mysql.
func LoadBackupTables ¶
func LoadBackupTables(ctx context.Context, reader *metautil.MetaReader) (map[string]*Database, error)
LoadBackupTables loads schemas from BackupMeta.
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 NeedAutoID ¶
NeedAutoID checks whether the table needs backing up with an autoid.
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 StartDynamicPProfListener ¶
StartDynamicPProfListener starts the listener that will enable pprof when received `startPProfSignal`.
func StartPProfListener ¶
StartPProfListener forks a new goroutine listening on specified port and provide pprof info.
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 TemporaryDBName ¶
TemporaryDBName makes a 'private' database name.
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.
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.
type BytesBuffer ¶
type BytesBuffer struct {
// contains filtered or unexported fields
}
BytesBuffer represents the reuse buffer.
func (*BytesBuffer) AddBytes ¶
func (b *BytesBuffer) AddBytes(bytes []byte) []byte
AddBytes add the bytes into this BytesBuffer.
func (*BytesBuffer) TotalSize ¶
func (b *BytesBuffer) TotalSize() int64
TotalSize represents the total memory size of this BytesBuffer.
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 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) RecycleWorker ¶
func (pool *WorkerPool) RecycleWorker(worker *Worker)
RecycleWorker recycle a worker.