Documentation ¶
Index ¶
- func DecodeTableID(key []byte) (model.TableID, error)
- func GetNewJobWithArgs(job *timodel.Job, args timodel.JobArgs) (*timodel.Job, error)
- func InitMetrics(registry *prometheus.Registry)
- func IsLegacyFormatJob(rawKV *model.RawKVEntry) bool
- func NewMounterGroup(schemaStorage SchemaStorage, workerNum int, filter filter.Filter, ...) *mounterGroup
- func ParseDDLJob(tblInfo *model.TableInfo, rawKV *model.RawKVEntry, id int64) (*timodel.Job, error)
- func VerifyTables(f filter.Filter, storage tidbkv.Storage, startTs uint64) (tableInfos []*model.TableInfo, ...)
- type MetaType
- type MockMountGroup
- func (m *MockMountGroup) AddEvent(ctx context.Context, event *model.PolymorphicEvent) error
- func (m *MockMountGroup) Close()
- func (m *MockMountGroup) Run(ctx context.Context, _ ...chan<- error) error
- func (m *MockMountGroup) TryAddEvent(ctx context.Context, event *model.PolymorphicEvent) (bool, error)
- func (m *MockMountGroup) WaitForReady(_ context.Context)
- type MockSchemaStorage
- func (s *MockSchemaStorage) AdvanceResolvedTs(ts uint64)
- func (s *MockSchemaStorage) AllPhysicalTables(ctx context.Context, ts model.Ts) ([]model.TableID, error)
- func (s *MockSchemaStorage) AllTables(ctx context.Context, ts model.Ts) ([]*model.TableInfo, error)
- func (s *MockSchemaStorage) BuildDDLEvents(_ context.Context, _ *timodel.Job) (ddlEvents []*model.DDLEvent, err error)
- func (s *MockSchemaStorage) DoGC(ts uint64) uint64
- func (s *MockSchemaStorage) GetLastSnapshot() *schema.Snapshot
- func (s *MockSchemaStorage) GetSnapshot(ctx context.Context, ts uint64) (*schema.Snapshot, error)
- func (s *MockSchemaStorage) HandleDDLJob(job *timodel.Job) error
- func (s *MockSchemaStorage) IsIneligibleTable(ctx context.Context, tableID model.TableID, ts model.Ts) (bool, error)
- func (s *MockSchemaStorage) ResolvedTs() uint64
- type Mounter
- type MounterGroup
- type SchemaStorage
- type SchemaTestHelper
- func (s *SchemaTestHelper) Close()
- func (s *SchemaTestHelper) DDL2Event(ddl string) *model.DDLEvent
- func (s *SchemaTestHelper) DDL2Job(ddl string) *timodel.Job
- func (s *SchemaTestHelper) DDL2Jobs(ddl string, jobCnt int) []*timodel.Job
- func (s *SchemaTestHelper) DML2Event(dml string, schema, table string, partitionID ...string) *model.RowChangedEvent
- func (s *SchemaTestHelper) GetCurrentMeta() timeta.Reader
- func (s *SchemaTestHelper) SchemaStorage() SchemaStorage
- func (s *SchemaTestHelper) Storage() kv.Storage
- func (s *SchemaTestHelper) Tk() *testkit.TestKit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeTableID ¶
DecodeTableID decodes the raw key to a table ID
func GetNewJobWithArgs ¶
GetNewJobWithArgs returns a new job with the given args
func InitMetrics ¶
func InitMetrics(registry *prometheus.Registry)
InitMetrics registers all metrics in this file
func IsLegacyFormatJob ¶
func IsLegacyFormatJob(rawKV *model.RawKVEntry) bool
IsLegacyFormatJob returns true if the job is from the legacy DDL list key.
func NewMounterGroup ¶
func NewMounterGroup( schemaStorage SchemaStorage, workerNum int, filter filter.Filter, tz *time.Location, changefeedID model.ChangeFeedID, integrity *integrity.Config, ) *mounterGroup
NewMounterGroup return a group of mounters.
func ParseDDLJob ¶
ParseDDLJob parses the job from the raw KV entry. id is the column id of `job_meta`.
func VerifyTables ¶
func VerifyTables( f filter.Filter, storage tidbkv.Storage, startTs uint64) ( tableInfos []*model.TableInfo, ineligibleTables, eligibleTables []model.TableName, err error, )
VerifyTables catalog tables specified by ReplicaConfig into eligible (has an unique index or primary key) and ineligible tables.
Types ¶
type MetaType ¶
type MetaType byte
MetaType is for data structure meta/data flag.
const ( // UnknownMetaType is used for all unknown meta types UnknownMetaType MetaType = 0 // StringMeta is the flag for string meta. StringMeta MetaType = 'S' // StringData is the flag for string data. StringData MetaType = 's' // HashMeta is the flag for hash meta. HashMeta MetaType = 'H' // HashData is the flag for hash data. HashData MetaType = 'h' // ListMeta is the flag for list meta. ListMeta MetaType = 'L' // ListData is the flag for list data. ListData MetaType = 'l' )
type MockMountGroup ¶
type MockMountGroup struct {
IsFull bool
}
MockMountGroup is used for tests.
func (*MockMountGroup) AddEvent ¶
func (m *MockMountGroup) AddEvent(ctx context.Context, event *model.PolymorphicEvent) error
AddEvent implements MountGroup.
func (*MockMountGroup) Run ¶
func (m *MockMountGroup) Run(ctx context.Context, _ ...chan<- error) error
Run implements util.Runnable.
func (*MockMountGroup) TryAddEvent ¶
func (m *MockMountGroup) TryAddEvent(ctx context.Context, event *model.PolymorphicEvent) (bool, error)
TryAddEvent implements MountGroup.
func (*MockMountGroup) WaitForReady ¶
func (m *MockMountGroup) WaitForReady(_ context.Context)
WaitForReady implements util.Runnable.
type MockSchemaStorage ¶
type MockSchemaStorage struct {
Resolved uint64
}
MockSchemaStorage is for tests.
func (*MockSchemaStorage) AdvanceResolvedTs ¶
func (s *MockSchemaStorage) AdvanceResolvedTs(ts uint64)
AdvanceResolvedTs implements SchemaStorage.
func (*MockSchemaStorage) AllPhysicalTables ¶
func (s *MockSchemaStorage) AllPhysicalTables(ctx context.Context, ts model.Ts) ([]model.TableID, error)
AllPhysicalTables implements SchemaStorage.
func (*MockSchemaStorage) BuildDDLEvents ¶
func (s *MockSchemaStorage) BuildDDLEvents( _ context.Context, _ *timodel.Job, ) (ddlEvents []*model.DDLEvent, err error)
BuildDDLEvents implements SchemaStorage.
func (*MockSchemaStorage) DoGC ¶
func (s *MockSchemaStorage) DoGC(ts uint64) uint64
DoGC implements SchemaStorage.
func (*MockSchemaStorage) GetLastSnapshot ¶
func (s *MockSchemaStorage) GetLastSnapshot() *schema.Snapshot
GetLastSnapshot implements SchemaStorage.
func (*MockSchemaStorage) GetSnapshot ¶
GetSnapshot implements SchemaStorage.
func (*MockSchemaStorage) HandleDDLJob ¶
func (s *MockSchemaStorage) HandleDDLJob(job *timodel.Job) error
HandleDDLJob implements SchemaStorage.
func (*MockSchemaStorage) IsIneligibleTable ¶
func (s *MockSchemaStorage) IsIneligibleTable(ctx context.Context, tableID model.TableID, ts model.Ts) (bool, error)
IsIneligibleTable implements SchemaStorage.
func (*MockSchemaStorage) ResolvedTs ¶
func (s *MockSchemaStorage) ResolvedTs() uint64
ResolvedTs implements SchemaStorage.
type Mounter ¶
type Mounter interface { // DecodeEvent accepts `model.PolymorphicEvent` with `RawKVEntry` filled and // decodes `RawKVEntry` into `RowChangedEvent`. // If a `model.PolymorphicEvent` should be ignored, it will returns (false, nil). DecodeEvent(ctx context.Context, event *model.PolymorphicEvent) error }
Mounter is used to parse SQL events from KV events
func NewMounter ¶
func NewMounter(schemaStorage SchemaStorage, changefeedID model.ChangeFeedID, tz *time.Location, filter pfilter.Filter, integrity *integrity.Config, ) Mounter
NewMounter creates a mounter
type MounterGroup ¶
type MounterGroup interface { util.Runnable AddEvent(ctx context.Context, event *model.PolymorphicEvent) error TryAddEvent(ctx context.Context, event *model.PolymorphicEvent) (bool, error) }
MounterGroup is a group of mounter workers
type SchemaStorage ¶
type SchemaStorage interface { // GetSnapshot returns the nearest snapshot which currentTs is less than or // equal to the ts. // It may block caller when ts is larger than the resolvedTs of SchemaStorage. GetSnapshot(ctx context.Context, ts uint64) (*schema.Snapshot, error) // GetLastSnapshot returns the last snapshot GetLastSnapshot() *schema.Snapshot // HandleDDLJob creates a new snapshot in storage and handles the ddl job HandleDDLJob(job *timodel.Job) error // AllPhysicalTables returns the table IDs of all tables and partition tables. AllPhysicalTables(ctx context.Context, ts model.Ts) ([]model.TableID, error) // AllTables returns table info of all tables that are being replicated. AllTables(ctx context.Context, ts model.Ts) ([]*model.TableInfo, error) // BuildDDLEvents by parsing the DDL job BuildDDLEvents(ctx context.Context, job *timodel.Job) (ddlEvents []*model.DDLEvent, err error) // IsIneligibleTable returns whether the table is ineligible. // Ineligible means that the table does not have a primary key or unique key. IsIneligibleTable(ctx context.Context, tableID model.TableID, ts model.Ts) (bool, error) // AdvanceResolvedTs advances the resolved ts AdvanceResolvedTs(ts uint64) // ResolvedTs returns the resolved ts of the schema storage ResolvedTs() uint64 // DoGC removes snaps that are no longer needed at the specified TS. // It returns the TS from which the oldest maintained snapshot is valid. DoGC(ts uint64) (lastSchemaTs uint64) }
SchemaStorage stores the schema information with multi-version
func NewSchemaStorage ¶
func NewSchemaStorage( storage tidbkv.Storage, startTs uint64, forceReplicate bool, id model.ChangeFeedID, role util.Role, filter filter.Filter, ) (SchemaStorage, error)
NewSchemaStorage creates a new schema storage
type SchemaTestHelper ¶
type SchemaTestHelper struct {
// contains filtered or unexported fields
}
SchemaTestHelper is a test helper for schema which creates an internal tidb instance to generate DDL jobs with meta information
func NewSchemaTestHelper ¶
func NewSchemaTestHelper(t testing.TB) *SchemaTestHelper
NewSchemaTestHelper creates a SchemaTestHelper
func NewSchemaTestHelperWithReplicaConfig ¶
func NewSchemaTestHelperWithReplicaConfig( t testing.TB, replicaConfig *config.ReplicaConfig, ) *SchemaTestHelper
NewSchemaTestHelperWithReplicaConfig creates a SchemaTestHelper by using the given replica config.
func (*SchemaTestHelper) DDL2Event ¶
func (s *SchemaTestHelper) DDL2Event(ddl string) *model.DDLEvent
DDL2Event executes the DDL and return the corresponding event.
func (*SchemaTestHelper) DDL2Job ¶
func (s *SchemaTestHelper) DDL2Job(ddl string) *timodel.Job
DDL2Job executes the DDL stmt and returns the DDL job
func (*SchemaTestHelper) DDL2Jobs ¶
func (s *SchemaTestHelper) DDL2Jobs(ddl string, jobCnt int) []*timodel.Job
DDL2Jobs executes the DDL statement and return the corresponding DDL jobs. It is mainly used for "DROP TABLE" and "DROP VIEW" statement because multiple jobs will be generated after executing these two types of DDL statements.
func (*SchemaTestHelper) DML2Event ¶
func (s *SchemaTestHelper) DML2Event(dml string, schema, table string, partitionID ...string) *model.RowChangedEvent
DML2Event execute the dml and return the corresponding row changed event. caution: it does not support `delete` since the key value cannot be found after the query executed.
func (*SchemaTestHelper) GetCurrentMeta ¶
func (s *SchemaTestHelper) GetCurrentMeta() timeta.Reader
GetCurrentMeta return the current meta snapshot
func (*SchemaTestHelper) SchemaStorage ¶
func (s *SchemaTestHelper) SchemaStorage() SchemaStorage
SchemaStorage returns the schema storage
func (*SchemaTestHelper) Storage ¶
func (s *SchemaTestHelper) Storage() kv.Storage
Storage returns the tikv storage
func (*SchemaTestHelper) Tk ¶
func (s *SchemaTestHelper) Tk() *testkit.TestKit
Tk returns the TestKit