Documentation ¶
Index ¶
- Constants
- Variables
- type MemSyncer
- func (*MemSyncer) Close()
- func (s *MemSyncer) CloseSession()
- func (s *MemSyncer) Done() <-chan struct{}
- func (s *MemSyncer) GlobalVersionCh() clientv3.WatchChan
- func (s *MemSyncer) Init(_ context.Context) error
- func (s *MemSyncer) OwnerUpdateGlobalVersion(_ context.Context, _ int64) error
- func (s *MemSyncer) Restart(_ context.Context) error
- func (*MemSyncer) SyncJobSchemaVerLoop(context.Context)
- func (s *MemSyncer) UpdateSelfVersion(_ context.Context, jobID int64, version int64) error
- func (s *MemSyncer) WaitVersionSynced(ctx context.Context, jobID int64, latestVer int64) error
- func (*MemSyncer) WatchGlobalSchemaVer(context.Context)
- type Syncer
Constants ¶
const ( // InitialVersion is the initial schema version for every server. // It's exported for testing. InitialVersion = "0" )
Variables ¶
var ( // CheckVersFirstWaitTime is a waitting time before the owner checks all the servers of the schema version, // and it's an exported variable for testing. CheckVersFirstWaitTime = 50 * time.Millisecond )
Functions ¶
This section is empty.
Types ¶
type MemSyncer ¶
type MemSyncer struct {
// contains filtered or unexported fields
}
MemSyncer is in memory schema version syncer, used for uni-store where there is only 1 TiDB instance. it's mainly for test. exported for testing.
func (*MemSyncer) CloseSession ¶
func (s *MemSyncer) CloseSession()
CloseSession mockSession, it is exported for testing.
func (*MemSyncer) Done ¶
func (s *MemSyncer) Done() <-chan struct{}
Done implements Syncer.Done interface.
func (*MemSyncer) GlobalVersionCh ¶
GlobalVersionCh implements Syncer.GlobalVersionCh interface.
func (*MemSyncer) OwnerUpdateGlobalVersion ¶
OwnerUpdateGlobalVersion implements Syncer.OwnerUpdateGlobalVersion interface.
func (*MemSyncer) SyncJobSchemaVerLoop ¶
SyncJobSchemaVerLoop implements Syncer.SyncJobSchemaVerLoop interface.
func (*MemSyncer) UpdateSelfVersion ¶
UpdateSelfVersion implements Syncer.UpdateSelfVersion interface.
func (*MemSyncer) WaitVersionSynced ¶
WaitVersionSynced implements Syncer.WaitVersionSynced interface.
func (*MemSyncer) WatchGlobalSchemaVer ¶
WatchGlobalSchemaVer implements Syncer.WatchGlobalSchemaVer interface.
type Syncer ¶
type Syncer interface { // Init sets the global schema version path to etcd if it isn't exist, // then watch this path, and initializes the self schema version to etcd. Init(ctx context.Context) error // UpdateSelfVersion updates the current version to the self path on etcd. UpdateSelfVersion(ctx context.Context, jobID int64, version int64) error // OwnerUpdateGlobalVersion updates the latest version to the global path on etcd until updating is successful or the ctx is done. OwnerUpdateGlobalVersion(ctx context.Context, version int64) error // GlobalVersionCh gets the chan for watching global version. GlobalVersionCh() clientv3.WatchChan // WatchGlobalSchemaVer watches the global schema version. WatchGlobalSchemaVer(ctx context.Context) // Done returns a channel that closes when the syncer is no longer being refreshed. Done() <-chan struct{} // Restart restarts the syncer when it's on longer being refreshed. Restart(ctx context.Context) error // WaitVersionSynced wait until all servers' current schema version are equal // or greater than latestVer. WaitVersionSynced(ctx context.Context, jobID int64, latestVer int64) error // SyncJobSchemaVerLoop syncs the schema versions on all TiDB nodes for DDL jobs. SyncJobSchemaVerLoop(ctx context.Context) // Close ends Syncer. Close() }
Syncer is used to synchronize schema version between the DDL owner and follower. DDL owner and follower only depends on a subset of the methods of Syncer. DDL owner will use this interface to update the global schema version, and wait all followers to update schema to the target version. followers use it to receive version change events, reload schema and update their version.
func NewEtcdSyncer ¶
NewEtcdSyncer creates a new Syncer.