Documentation ¶
Index ¶
- Constants
- func GetNextBytesHandleDatum(key kv.Key, recordPrefix []byte) (d types.Datum)
- func GetNextIntHandle(key kv.Key, recordPrefix []byte) kv.Handle
- func InsertIntoTTLTask(sctx sessionctx.Context, jobID string, tableID int64, scanID int, ...) (string, []interface{}, error)
- func PeekWaitingTTLTask(hbExpire time.Time) (string, []interface{})
- func SelectFromTTLTableStatusWithID(tableID int64) (string, []interface{})
- func SelectFromTTLTaskWithID(jobID string, scanID int64) (string, []interface{})
- func SelectFromTTLTaskWithJobID(jobID string) (string, []interface{})
- type InfoSchemaCache
- type JobStatus
- type PhysicalTable
- func (t *PhysicalTable) EvalExpireTime(ctx context.Context, se session.Session, now time.Time) (expire time.Time, err error)
- func (t *PhysicalTable) SplitScanRanges(ctx context.Context, store kv.Storage, splitCnt int) ([]ScanRange, error)
- func (t *PhysicalTable) ValidateKeyPrefix(key []types.Datum) error
- type ScanRange
- type TTLTask
- type TTLTaskState
- type TableStatus
- type TableStatusCache
- type TaskStatus
Constants ¶
const ( // TaskStatusWaiting means the task hasn't started TaskStatusWaiting TaskStatus = "waiting" // TaskStatusRunning means this task is running TaskStatusRunning = "running" // TaskStatusFinished means this task has finished TaskStatusFinished = "finished" )
Variables ¶
This section is empty.
Functions ¶
func GetNextBytesHandleDatum ¶
GetNextBytesHandleDatum is used for a table with one binary or string column common handle. It returns the minValue whose encoded key is or after argument `key` If it cannot find a valid value, a null datum will be returned.
func GetNextIntHandle ¶
GetNextIntHandle is used for int handle tables. It returns the min handle whose encoded key is or after argument `key` If it cannot find a valid value, a null datum will be returned.
func InsertIntoTTLTask ¶
func InsertIntoTTLTask(sctx sessionctx.Context, jobID string, tableID int64, scanID int, scanRangeStart []types.Datum, scanRangeEnd []types.Datum, expireTime time.Time, createdTime time.Time) (string, []interface{}, error)
InsertIntoTTLTask returns an SQL statement to insert a ttl task into mysql.tidb_ttl_task
func PeekWaitingTTLTask ¶
PeekWaitingTTLTask returns an SQL statement to get `limit` waiting ttl task
func SelectFromTTLTableStatusWithID ¶
SelectFromTTLTableStatusWithID returns an SQL statement to get the table status from table id
func SelectFromTTLTaskWithID ¶
SelectFromTTLTaskWithID returns an SQL statement to get all tasks of the specified job and scanID in mysql.tidb_ttl_task
func SelectFromTTLTaskWithJobID ¶
SelectFromTTLTaskWithJobID returns an SQL statement to get all tasks of the specified job in mysql.tidb_ttl_task
Types ¶
type InfoSchemaCache ¶
type InfoSchemaCache struct { Tables map[int64]*PhysicalTable // contains filtered or unexported fields }
InfoSchemaCache is the cache for InfoSchema, it builds a map from physical table id to physical table information
func NewInfoSchemaCache ¶
func NewInfoSchemaCache(updateInterval time.Duration) *InfoSchemaCache
NewInfoSchemaCache creates the cache for info schema
func (*InfoSchemaCache) GetInterval ¶
func (*InfoSchemaCache) SetInterval ¶
SetInterval sets the interval of updating cache
func (*InfoSchemaCache) ShouldUpdate ¶
func (bc *InfoSchemaCache) ShouldUpdate() bool
ShouldUpdate returns whether this cache needs update
type JobStatus ¶
type JobStatus string
JobStatus represents the current status of a job
const ( // JobStatusWaiting means the job hasn't started JobStatusWaiting JobStatus = "waiting" // JobStatusRunning means this job is running JobStatusRunning JobStatus = "running" // JobStatusCancelling means this job is being canceled, but not canceled yet JobStatusCancelling JobStatus = "cancelling" // JobStatusCancelled means this job has been canceled successfully JobStatusCancelled JobStatus = "cancelled" // JobStatusTimeout means this job has timeout JobStatusTimeout JobStatus = "timeout" // JobStatusFinished means job has been finished JobStatusFinished JobStatus = "finished" )
type PhysicalTable ¶
type PhysicalTable struct { // ID is the physical ID of the table ID int64 // Schema is the database name of the table Schema model.CIStr *model.TableInfo // Partition is the partition name Partition model.CIStr // PartitionDef is the partition definition PartitionDef *model.PartitionDefinition // KeyColumns is the cluster index key columns for the table KeyColumns []*model.ColumnInfo // KeyColumnTypes is the types of the key columns KeyColumnTypes []*types.FieldType // TimeColum is the time column used for TTL TimeColumn *model.ColumnInfo }
PhysicalTable is used to provide some information for a physical table in TTL job
func NewPhysicalTable ¶
func NewPhysicalTable(schema model.CIStr, tbl *model.TableInfo, partition model.CIStr) (*PhysicalTable, error)
NewPhysicalTable create a new PhysicalTable
func (*PhysicalTable) EvalExpireTime ¶
func (t *PhysicalTable) EvalExpireTime(ctx context.Context, se session.Session, now time.Time) (expire time.Time, err error)
EvalExpireTime returns the expired time
func (*PhysicalTable) SplitScanRanges ¶
func (t *PhysicalTable) SplitScanRanges(ctx context.Context, store kv.Storage, splitCnt int) ([]ScanRange, error)
SplitScanRanges split ranges for TTL scan
func (*PhysicalTable) ValidateKeyPrefix ¶
func (t *PhysicalTable) ValidateKeyPrefix(key []types.Datum) error
ValidateKeyPrefix validates a key prefix
type TTLTask ¶
type TTLTask struct { JobID string TableID int64 ScanID int64 ScanRangeStart []types.Datum ScanRangeEnd []types.Datum ExpireTime time.Time OwnerID string OwnerAddr string OwnerHBTime time.Time Status TaskStatus StatusUpdateTime time.Time State *TTLTaskState CreatedTime time.Time }
TTLTask is a row recorded in mysql.tidb_ttl_task
func RowToTTLTask ¶
RowToTTLTask converts a row into TTL task
type TTLTaskState ¶
type TTLTaskState struct { TotalRows uint64 `json:"total_rows"` SuccessRows uint64 `json:"success_rows"` ErrorRows uint64 `json:"error_rows"` ScanTaskErr string `json:"scan_task_err"` }
TTLTaskState records the internal states of the ttl task
type TableStatus ¶
type TableStatus struct { TableID int64 ParentTableID int64 TableStatistics string LastJobID string LastJobStartTime time.Time LastJobFinishTime time.Time LastJobTTLExpire time.Time LastJobSummary string CurrentJobID string CurrentJobOwnerID string CurrentJobOwnerAddr string CurrentJobOwnerHBTime time.Time CurrentJobStartTime time.Time CurrentJobTTLExpire time.Time CurrentJobState string CurrentJobStatus JobStatus CurrentJobStatusUpdateTime time.Time }
TableStatus contains the corresponding information in the system table `mysql.tidb_ttl_table_status`
func RowToTableStatus ¶
func RowToTableStatus(sctx sessionctx.Context, row chunk.Row) (*TableStatus, error)
RowToTableStatus converts a row to table status
type TableStatusCache ¶
type TableStatusCache struct { Tables map[int64]*TableStatus // contains filtered or unexported fields }
TableStatusCache is the cache for ttl table status, it builds a map from physical table id to the table status
func NewTableStatusCache ¶
func NewTableStatusCache(updateInterval time.Duration) *TableStatusCache
NewTableStatusCache creates cache for ttl table status
func (*TableStatusCache) GetInterval ¶
func (*TableStatusCache) SetInterval ¶
SetInterval sets the interval of updating cache
func (*TableStatusCache) ShouldUpdate ¶
func (bc *TableStatusCache) ShouldUpdate() bool
ShouldUpdate returns whether this cache needs update