backup

package
v4.0.12+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 42 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultSchemaConcurrency is the default number of the concurrent
	// backup schema tasks.
	DefaultSchemaConcurrency = 64
)

Variables

This section is empty.

Functions

func BuildBackupMeta

func BuildBackupMeta(
	req *kvproto.BackupRequest,
	files []*kvproto.File,
	rawRanges []*kvproto.RawRange,
	ddlJobs []*model.Job,
) (backupMeta kvproto.BackupMeta, err error)

BuildBackupMeta constructs the backup meta file from its components.

func BuildTableRanges

func BuildTableRanges(tbl *model.TableInfo) ([]kv.KeyRange, error)

BuildTableRanges returns the key ranges encompassing the entire table, and its partitions if exists.

func ChecksumMatches

func ChecksumMatches(backupMeta *kvproto.BackupMeta, local []Checksum) error

ChecksumMatches tests whether the "local" checksum matches the checksum from TiKV.

func FilterSchema

func FilterSchema(backupMeta *kvproto.BackupMeta) error

FilterSchema filter in-place schemas that doesn't have backup files this is useful during incremental backup, no files in backup means no files to restore so we can skip some DDL in restore to speed up restoration.

func GetBackupDDLJobs

func GetBackupDDLJobs(dom *domain.Domain, lastBackupTS, backupTS uint64) ([]*model.Job, error)

GetBackupDDLJobs returns the ddl jobs are done in (lastBackupTS, backupTS].

func OnBackupResponse

func OnBackupResponse(
	storeID uint64,
	bo *tikv.Backoffer,
	backupTS uint64,
	lockResolver *tikv.LockResolver,
	resp *kvproto.BackupResponse,
) (*kvproto.BackupResponse, int, error)

OnBackupResponse checks the backup resp, decides whether to retry and generate the error.

func SendBackup

func SendBackup(
	ctx context.Context,
	storeID uint64,
	client kvproto.BackupClient,
	req kvproto.BackupRequest,
	respFn func(*kvproto.BackupResponse) error,
	resetFn func() (kvproto.BackupClient, error),
) error

SendBackup send backup request to the given store. Stop receiving response if respFn returns error.

Types

type Checksum

type Checksum struct {
	Crc64Xor   uint64
	TotalKvs   uint64
	TotalBytes uint64
}

Checksum is the checksum of some backup files calculated by CollectChecksums.

func CollectChecksums

func CollectChecksums(backupMeta *kvproto.BackupMeta) ([]Checksum, error)

CollectChecksums check data integrity by xor all(sst_checksum) per table it returns the checksum of all local files.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client instructs TiKV how to do a backup.

func NewBackupClient

func NewBackupClient(ctx context.Context, mgr ClientMgr) (*Client, error)

NewBackupClient returns a new backup client.

func (*Client) BackupRange

func (bc *Client) BackupRange(
	ctx context.Context,
	startKey, endKey []byte,
	req kvproto.BackupRequest,
	updateCh glue.Progress,
) (files []*kvproto.File, err error)

BackupRange make a backup of the given key range. Returns an array of files backed up.

func (*Client) BackupRanges

func (bc *Client) BackupRanges(
	ctx context.Context,
	ranges []rtree.Range,
	req kvproto.BackupRequest,
	concurrency uint,
	updateCh glue.Progress,
) ([]*kvproto.File, error)

BackupRanges make a backup of the given key ranges.

func (*Client) GetGCTTL

func (bc *Client) GetGCTTL() int64

GetGCTTL get gcTTL for this backup.

func (*Client) GetTS

func (bc *Client) GetTS(ctx context.Context, duration time.Duration, ts uint64) (uint64, error)

GetTS returns the latest timestamp.

func (*Client) SaveBackupMeta

func (bc *Client) SaveBackupMeta(ctx context.Context, backupMeta *kvproto.BackupMeta) error

SaveBackupMeta saves the current backup meta at the given path.

func (*Client) SetGCTTL

func (bc *Client) SetGCTTL(ttl int64)

SetGCTTL set gcTTL for client.

func (*Client) SetLockFile

func (bc *Client) SetLockFile(ctx context.Context) error

SetLockFile set write lock file.

func (*Client) SetStorage

func (bc *Client) SetStorage(ctx context.Context, backend *kvproto.StorageBackend, sendCreds bool) error

SetStorage set ExternalStorage for client.

type ClientMgr

type ClientMgr interface {
	GetBackupClient(ctx context.Context, storeID uint64) (kvproto.BackupClient, error)
	ResetBackupClient(ctx context.Context, storeID uint64) (kvproto.BackupClient, error)
	GetPDClient() pd.Client
	GetTiKV() tikv.Storage
	GetLockResolver() *tikv.LockResolver
	Close()
}

ClientMgr manages connections needed by backup.

type Schemas

type Schemas struct {
	// contains filtered or unexported fields
}

Schemas is task for backuping schemas.

func BuildBackupRangeAndSchema

func BuildBackupRangeAndSchema(
	dom *domain.Domain,
	storage kv.Storage,
	tableFilter filter.Filter,
	backupTS uint64,
	ignoreStats bool,
) ([]rtree.Range, *Schemas, error)

BuildBackupRangeAndSchema gets the range and schema of tables.

func (*Schemas) CopyMeta

func (pending *Schemas) CopyMeta() []*backup.Schema

CopyMeta copies schema metadata directly from pending backupSchemas, without calculating checksum. use this when user skip the checksum generating.

func (*Schemas) FinishTableChecksum

func (pending *Schemas) FinishTableChecksum() ([]*backup.Schema, error)

FinishTableChecksum waits until all schemas' checksums are verified.

func (*Schemas) Len

func (pending *Schemas) Len() int

Len returns the number of schemas.

func (*Schemas) Start

func (pending *Schemas) Start(
	ctx context.Context,
	store kv.Storage,
	backupTS uint64,
	concurrency uint,
	copConcurrency uint,
	updateCh glue.Progress,
)

Start backups schemas.

Jump to

Keyboard shortcuts

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