schemaver

package
v1.1.0-beta.0...-3c40731 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

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 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) Close

func (*MemSyncer) Close()

Close implements Syncer.Close interface.

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

func (s *MemSyncer) GlobalVersionCh() clientv3.WatchChan

GlobalVersionCh implements Syncer.GlobalVersionCh interface.

func (*MemSyncer) Init

func (s *MemSyncer) Init(_ context.Context) error

Init implements Syncer.Init interface.

func (*MemSyncer) OwnerUpdateGlobalVersion

func (s *MemSyncer) OwnerUpdateGlobalVersion(_ context.Context, _ int64) error

OwnerUpdateGlobalVersion implements Syncer.OwnerUpdateGlobalVersion interface.

func (*MemSyncer) Restart

func (s *MemSyncer) Restart(_ context.Context) error

Restart implements Syncer.Restart interface.

func (*MemSyncer) SyncJobSchemaVerLoop

func (*MemSyncer) SyncJobSchemaVerLoop(context.Context)

SyncJobSchemaVerLoop implements Syncer.SyncJobSchemaVerLoop interface.

func (*MemSyncer) UpdateSelfVersion

func (s *MemSyncer) UpdateSelfVersion(_ context.Context, jobID int64, version int64) error

UpdateSelfVersion implements Syncer.UpdateSelfVersion interface.

func (*MemSyncer) WaitVersionSynced

func (s *MemSyncer) WaitVersionSynced(ctx context.Context, jobID int64, latestVer int64) error

WaitVersionSynced implements Syncer.WaitVersionSynced interface.

func (*MemSyncer) WatchGlobalSchemaVer

func (*MemSyncer) WatchGlobalSchemaVer(context.Context)

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

func NewEtcdSyncer(etcdCli *clientv3.Client, id string) Syncer

NewEtcdSyncer creates a new Syncer.

func NewMemSyncer

func NewMemSyncer() Syncer

NewMemSyncer creates a new memory Syncer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL