Documentation ¶
Index ¶
- Constants
- func BuildBackupSchemas(storage kv.Storage, tableFilter filter.Filter, backupTS uint64, ...) error
- func BuildFullSchema(storage kv.Storage, backupTS uint64, ...) error
- func CheckBackupStorageIsLocked(ctx context.Context, s storage.ExternalStorage) error
- func OnBackupResponse(storeID uint64, bo *tikv.Backoffer, backupTS uint64, ...) (*backuppb.BackupResponse, int, error)
- func SendBackup(ctx context.Context, storeID uint64, client backuppb.BackupClient, ...) error
- func WriteBackupDDLJobs(metaWriter *metautil.MetaWriter, g glue.Glue, store kv.Storage, ...) error
- type Checksum
- type Client
- func (bc *Client) BackupRange(ctx context.Context, request backuppb.BackupRequest, ...) (err error)
- func (bc *Client) BackupRanges(ctx context.Context, ranges []rtree.Range, request backuppb.BackupRequest, ...) error
- func (bc *Client) BuildBackupRangeAndSchema(storage kv.Storage, tableFilter filter.Filter, backupTS uint64, ...) ([]rtree.Range, *Schemas, []*backuppb.PlacementPolicy, error)
- func (bc *Client) CheckCheckpoint(hash []byte) error
- func (bc *Client) FindTargetPeer(ctx context.Context, key []byte, isRawKv bool, ...) (*metapb.Peer, error)
- func (bc *Client) GetApiVersion() kvrpcpb.APIVersion
- func (bc *Client) GetCheckpointRunner() ...
- func (bc *Client) GetClusterID() uint64
- func (bc *Client) GetCurrentTS(ctx context.Context) (uint64, error)
- func (bc *Client) GetGCTTL() int64
- func (bc *Client) GetProgressRange(r rtree.Range) (*rtree.ProgressRange, error)
- func (bc *Client) GetSafePointID() string
- func (bc *Client) GetStorage() storage.ExternalStorage
- func (bc *Client) GetStorageBackend() *backuppb.StorageBackend
- func (bc *Client) GetTS(ctx context.Context, duration time.Duration, ts uint64) (uint64, error)
- func (bc *Client) SetApiVersion(v kvrpcpb.APIVersion)
- func (bc *Client) SetCipher(cipher *backuppb.CipherInfo)
- func (bc *Client) SetGCTTL(ttl int64)
- func (bc *Client) SetLockFile(ctx context.Context) error
- func (bc *Client) SetStorage(ctx context.Context, backend *backuppb.StorageBackend, ...) error
- func (bc *Client) SetStorageAndCheckNotInUse(ctx context.Context, backend *backuppb.StorageBackend, ...) error
- func (bc *Client) StartCheckpointRunner(ctx context.Context, cfgHash []byte, backupTS uint64, ranges []rtree.Range, ...) (err error)
- func (bc *Client) WaitForFinishCheckpoint(ctx context.Context, flush bool)
- type ClientMgr
- type ProgressUnit
- type Schemas
- type StoreBasedErr
Constants ¶
const ( // DefaultSchemaConcurrency is the default number of the concurrent // backup schema tasks. DefaultSchemaConcurrency = 64 )
Variables ¶
This section is empty.
Functions ¶
func BuildBackupSchemas ¶
func BuildFullSchema ¶
func BuildFullSchema(storage kv.Storage, backupTS uint64, fn func(dbInfo *model.DBInfo, tableInfo *model.TableInfo)) error
BuildFullSchema builds a full backup schemas for databases and tables.
func CheckBackupStorageIsLocked ¶
func CheckBackupStorageIsLocked(ctx context.Context, s storage.ExternalStorage) error
CheckBackupStorageIsLocked checks whether backups is locked. which means we found other backup progress already write some data files into the same backup directory or cloud prefix.
func OnBackupResponse ¶
func OnBackupResponse( storeID uint64, bo *tikv.Backoffer, backupTS uint64, lockResolver *txnlock.LockResolver, resp *backuppb.BackupResponse, errContext *utils.ErrorContext, ) (*backuppb.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 backuppb.BackupClient, req backuppb.BackupRequest, respFn func(*backuppb.BackupResponse) error, resetFn func() (backuppb.BackupClient, error), ) error
SendBackup send backup request to the given store. Stop receiving response if respFn returns error.
Types ¶
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, request backuppb.BackupRequest, replicaReadLabel map[string]string, progressRange *rtree.ProgressRange, metaWriter *metautil.MetaWriter, progressCallBack func(ProgressUnit), ) (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, request backuppb.BackupRequest, concurrency uint, replicaReadLabel map[string]string, metaWriter *metautil.MetaWriter, progressCallBack func(ProgressUnit), ) error
BackupRanges make a backup of the given key ranges.
func (*Client) BuildBackupRangeAndSchema ¶
func (bc *Client) BuildBackupRangeAndSchema( storage kv.Storage, tableFilter filter.Filter, backupTS uint64, isFullBackup bool, ) ([]rtree.Range, *Schemas, []*backuppb.PlacementPolicy, error)
Client.BuildBackupRangeAndSchema calls BuildBackupRangeAndSchema, if the checkpoint mode is used, return the ranges from checkpoint meta
func (*Client) CheckCheckpoint ¶
CheckCheckpoint check whether the configs are the same
func (*Client) FindTargetPeer ¶
func (*Client) GetApiVersion ¶
func (bc *Client) GetApiVersion() kvrpcpb.APIVersion
GetApiVersion sets api version of the TiKV storage
func (*Client) GetCheckpointRunner ¶
func (bc *Client) GetCheckpointRunner() *checkpoint.CheckpointRunner[checkpoint.BackupKeyType, checkpoint.BackupValueType]
func (*Client) GetClusterID ¶
GetClusterID returns the cluster ID of the tidb cluster to backup.
func (*Client) GetCurrentTS ¶
GetCurrentTS gets a new timestamp from PD.
func (*Client) GetProgressRange ¶
GetProgressRange loads the checkpoint(finished) sub-ranges of the current range, and calculate its incompleted sub-ranges.
func (*Client) GetSafePointID ¶
GetSafePointID get the gc-safe-point's service-id from either checkpoint or immediate generation
func (*Client) GetStorage ¶
func (bc *Client) GetStorage() storage.ExternalStorage
GetStorage gets storage for this backup.
func (*Client) GetStorageBackend ¶
func (bc *Client) GetStorageBackend() *backuppb.StorageBackend
GetStorageBackend gets storage backupend field in client.
func (*Client) SetApiVersion ¶
func (bc *Client) SetApiVersion(v kvrpcpb.APIVersion)
SetApiVersion sets api version of the TiKV storage
func (*Client) SetCipher ¶
func (bc *Client) SetCipher(cipher *backuppb.CipherInfo)
SetCipher for checkpoint to encrypt sst file's metadata
func (*Client) SetLockFile ¶
SetLockFile set write lock file.
func (*Client) SetStorage ¶
func (bc *Client) SetStorage( ctx context.Context, backend *backuppb.StorageBackend, opts *storage.ExternalStorageOptions, ) error
SetStorage sets ExternalStorage for client.
func (*Client) SetStorageAndCheckNotInUse ¶
func (bc *Client) SetStorageAndCheckNotInUse( ctx context.Context, backend *backuppb.StorageBackend, opts *storage.ExternalStorageOptions, ) error
SetStorageAndCheckNotInUse sets ExternalStorage for client and check storage not in used by others.
func (*Client) StartCheckpointRunner ¶
func (bc *Client) StartCheckpointRunner( ctx context.Context, cfgHash []byte, backupTS uint64, ranges []rtree.Range, safePointID string, progressCallBack func(ProgressUnit), ) (err error)
StartCheckpointMeta will 1. saves the initial status into the external storage; 2. load the checkpoint data from external storage 3. start checkpoint runner
type ClientMgr ¶
type ClientMgr interface { GetBackupClient(ctx context.Context, storeID uint64) (backuppb.BackupClient, error) ResetBackupClient(ctx context.Context, storeID uint64) (backuppb.BackupClient, error) GetPDClient() pd.Client GetLockResolver() *txnlock.LockResolver Close() }
ClientMgr manages connections needed by backup.
type ProgressUnit ¶
type ProgressUnit string
ProgressUnit represents the unit of progress.
const ( // RangeUnit represents the progress updated counter when a range finished. RangeUnit ProgressUnit = "range" // RegionUnit represents the progress updated counter when a region finished. RegionUnit ProgressUnit = "region" )
type Schemas ¶
type Schemas struct {
// contains filtered or unexported fields
}
Schemas is task for backuping schemas.
func BuildBackupRangeAndInitSchema ¶
func BuildBackupRangeAndInitSchema( storage kv.Storage, tableFilter filter.Filter, backupTS uint64, isFullBackup bool, buildRange bool, ) ([]rtree.Range, *Schemas, []*backuppb.PlacementPolicy, error)
BuildBackupRangeAndSchema gets KV range and schema of tables. KV ranges are separated by Table IDs. Also, KV ranges are separated by Index IDs in the same table.
func NewBackupSchemas ¶
func (*Schemas) BackupSchemas ¶
func (ss *Schemas) BackupSchemas( ctx context.Context, metaWriter *metautil.MetaWriter, checkpointRunner *checkpoint.CheckpointRunner[checkpoint.BackupKeyType, checkpoint.BackupValueType], store kv.Storage, statsHandle *handle.Handle, backupTS uint64, concurrency uint, copConcurrency uint, skipChecksum bool, updateCh glue.Progress, ) error
BackupSchemas backups table info, including checksum and stats.
func (*Schemas) SetCheckpointChecksum ¶
func (ss *Schemas) SetCheckpointChecksum(checkpointChecksum map[int64]*checkpoint.ChecksumItem)
type StoreBasedErr ¶
type StoreBasedErr struct {
// contains filtered or unexported fields
}
func MakeStoreBasedErr ¶
func MakeStoreBasedErr(storeID uint64, err error) *StoreBasedErr
func (*StoreBasedErr) Cause ¶
func (e *StoreBasedErr) Cause() error
func (*StoreBasedErr) Error ¶
func (e *StoreBasedErr) Error() string
func (*StoreBasedErr) Errors ¶
func (e *StoreBasedErr) Errors() []error
Errors implements errors.ErrorGroup. For now `WalkDeep` cannot walk "subtree"s like:
1 - 2 - 5 * | * + 3 - 4
It stops after walking `1` and then gave up. This is a bug: see https://github.com/pingcap/errors/issues/72 We manually make this a multierr to workaround this...
func (*StoreBasedErr) Unwrap ¶
func (e *StoreBasedErr) Unwrap() error