Documentation ¶
Index ¶
Constants ¶
View Source
const ( // StateUpgrading represents the cluster global state is upgrading. It is exports for testing. StateUpgrading = "upgrading" // StateNormalRunning represents the cluster global state is normal running. It is exports for testing. StateNormalRunning = "" )
View Source
const ( // InitialVersion is the initial schema version for every server. // It's exported for testing. InitialVersion = "0" )
Variables ¶
View Source
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 SchemaSyncer ¶
type SchemaSyncer 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 // OwnerCheckAllVersions checks whether all followers' schema version are equal to // the latest schema version. (exclude the isolated TiDB) // It returns until all servers' versions are equal to the latest version. OwnerCheckAllVersions(ctx context.Context, jobID int64, latestVer int64) error // Close ends SchemaSyncer. Close() }
SchemaSyncer is used to synchronize schema version between the DDL worker leader and followers through etcd.
func NewSchemaSyncer ¶
func NewSchemaSyncer(etcdCli *clientv3.Client, id string) SchemaSyncer
NewSchemaSyncer creates a new SchemaSyncer.
type StateInfo ¶
type StateInfo struct {
State string `json:"state"`
}
StateInfo is the tidb cluster state. It will not be updated when the tidb cluster upgrading.
type StateSyncer ¶
type StateSyncer 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 // UpdateGlobalState updates the latest version to the global path on etcd until updating is successful or the ctx is done. UpdateGlobalState(ctx context.Context, stateInfo *StateInfo) error // GetGlobalState gets the global state from etcd. GetGlobalState(ctx context.Context) (*StateInfo, error) // IsUpgradingState returns whether the cluster state is upgrading. IsUpgradingState() bool WatchChan() clientv3.WatchChan Rewatch(ctx context.Context) }
StateSyncer is used to synchronize schema version between the DDL worker leader and followers through etcd.
func NewStateSyncer ¶
func NewStateSyncer(etcdCli *clientv3.Client, etcdPath string) StateSyncer
NewStateSyncer creates a new StateSyncer.
type Watcher ¶
type Watcher interface { // WatchChan returns the chan for watching etcd path. WatchChan() clientv3.WatchChan // Watch watches the etcd path. Watch(ctx context.Context, etcdCli *clientv3.Client, path string) // Rewatch rewatches the etcd path. Rewatch(ctx context.Context, etcdCli *clientv3.Client, path string) }
Watcher is responsible for watching the etcd path related operations.
Click to show internal directories.
Click to hide internal directories.