Documentation ¶
Index ¶
- Constants
- func BuildBackupMeta(req *kvproto.BackupRequest, files []*kvproto.File, ...) (backupMeta kvproto.BackupMeta, err error)
- func BuildTableRanges(tbl *model.TableInfo) ([]kv.KeyRange, error)
- func ChecksumMatches(backupMeta *kvproto.BackupMeta, local []Checksum) error
- func FilterSchema(backupMeta *kvproto.BackupMeta) error
- func GetBackupDDLJobs(dom *domain.Domain, lastBackupTS, backupTS uint64) ([]*model.Job, error)
- func OnBackupResponse(storeID uint64, bo *tikv.Backoffer, backupTS uint64, ...) (*kvproto.BackupResponse, int, error)
- func ReadJSONBody(body io.ReadCloser, out interface{}) error
- func SendBackup(ctx context.Context, storeID uint64, client kvproto.BackupClient, ...) error
- type Checksum
- type Client
- func (bc *Client) BackupRange(ctx context.Context, startKey, endKey []byte, req kvproto.BackupRequest, ...) (files []*kvproto.File, err error)
- func (bc *Client) BackupRanges(ctx context.Context, ranges []rtree.Range, req kvproto.BackupRequest, ...) ([]*kvproto.File, error)
- func (bc *Client) GetGCTTL() int64
- func (bc *Client) GetTS(ctx context.Context, duration time.Duration, ts uint64) (uint64, error)
- func (bc *Client) SaveBackupMeta(ctx context.Context, backupMeta *kvproto.BackupMeta) error
- func (bc *Client) SetGCTTL(ttl int64)
- func (bc *Client) SetLockFile(ctx context.Context) error
- func (bc *Client) SetStorage(ctx context.Context, backend *kvproto.StorageBackend, sendCreds bool) error
- type ClientMgr
- type Leader
- type Region
- type RegionResponse
- type Schemas
Constants ¶
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 ¶
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 ¶
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 ReadJSONBody ¶
func ReadJSONBody(body io.ReadCloser, out interface{}) error
ReadJSONBody read from ReadCloser and unmarshal to out; `out` should be of POINTER type
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 ¶
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 ¶
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) SaveBackupMeta ¶
SaveBackupMeta saves the current backup meta at the given path.
func (*Client) SetLockFile ¶
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 Region ¶
type Region struct { ID int `json:"id"` StartKey string `json:"start_key"` EndKey string `json:"end_key"` Leader Leader `json:"leader"` ApproximateKeys int `json:"approximate_keys"` }
Region represents info of unique region
func FetchRegions ¶
FetchRegions will fetch all tikv regions
type RegionResponse ¶
RegionResponse represents of all regions
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 ¶
CopyMeta copies schema metadata directly from pending backupSchemas, without calculating checksum. use this when user skip the checksum generating.
func (*Schemas) FinishTableChecksum ¶
FinishTableChecksum waits until all schemas' checksums are verified.