Documentation ¶
Index ¶
- func EvalExpireTime(now time.Time, interval string, unit ast.TimeUnitType) (time.Time, error)
- func GetASCIIPrefixDatumFromBytes(bs []byte) types.Datum
- func GetNextBytesHandleDatum(key kv.Key, recordPrefix []byte) (d types.Datum)
- func GetNextIntDatumFromCommonHandle(key kv.Key, recordPrefix []byte, unsigned bool) (d types.Datum)
- func GetNextIntHandle(key kv.Key, recordPrefix []byte) kv.Handle
- func InsertIntoTTLTask(sctx sessionctx.Context, jobID string, tableID int64, scanID int, ...) (string, []any, error)
- func PeekWaitingTTLTask(hbExpire time.Time) (string, []any)
- func SelectFromTTLTableStatusWithID(tableID int64) (string, []any)
- func SelectFromTTLTaskWithID(jobID string, scanID int64) (string, []any)
- func SelectFromTTLTaskWithJobID(jobID string) (string, []any)
- func SetMockExpireTime(ctx context.Context, tm time.Time) context.Context
- type InfoSchemaCache
- type JobStatus
- type PhysicalTable
- type ScanRange
- type TTLTask
- type TTLTaskState
- type TableStatus
- type TableStatusCache
- type TaskStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvalExpireTime ¶
EvalExpireTime returns the expired time.
func GetASCIIPrefixDatumFromBytes ¶
GetASCIIPrefixDatumFromBytes is used to convert bytes to string datum which only contains ASCII prefix string. The ASCII prefix string only contains visible characters and `\t`, `\n`, `\r`. "abc" -> "abc" "\0abc" -> "" "ab\x01c" -> "ab" "ab\xffc" -> "ab" "ab\rc\xff" -> "ab\rc"
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 GetNextIntDatumFromCommonHandle ¶
func GetNextIntDatumFromCommonHandle(key kv.Key, recordPrefix []byte, unsigned bool) (d types.Datum)
GetNextIntDatumFromCommonHandle is used for common handle tables with int value. 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 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, []any, 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 pmodel.CIStr *model.TableInfo // Partition is the partition name Partition pmodel.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 NewBasePhysicalTable ¶
func NewBasePhysicalTable(schema pmodel.CIStr, tbl *model.TableInfo, partition pmodel.CIStr, timeColumn *model.ColumnInfo, ) (*PhysicalTable, error)
NewBasePhysicalTable create a new PhysicalTable with specific timeColumn.
func NewPhysicalTable ¶
func NewPhysicalTable(schema pmodel.CIStr, tbl *model.TableInfo, partition pmodel.CIStr) (*PhysicalTable, error)
NewPhysicalTable create a new PhysicalTable
func (*PhysicalTable) EvalExpireTime ¶
func (t *PhysicalTable) EvalExpireTime(ctx context.Context, se session.Session, now time.Time) (time.Time, error)
EvalExpireTime returns the expired time for the current time. It uses the global timezone in session to evaluation the context and the return time is in the same timezone of now argument.
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"` // When PreviousOwner != "", it means this task is resigned from another owner PreviousOwner string `json:"prev_owner,omitempty"` }
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
type TaskStatus ¶
type TaskStatus string
TaskStatus represents the current status of a task
const ( // TaskStatusWaiting means the task hasn't started TaskStatusWaiting TaskStatus = "waiting" // TaskStatusRunning means this task is running TaskStatusRunning TaskStatus = "running" // TaskStatusFinished means this task has finished TaskStatusFinished TaskStatus = "finished" )