domain

package
v2.0.10-binlog+incompa... Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2018 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ResultSucc means schemaValidator's check is passing.
	ResultSucc checkResult = iota
	// ResultFail means schemaValidator's check is fail.
	ResultFail
	// ResultUnknown means schemaValidator doesn't know the check would be success or fail.
	ResultUnknown
)

Variables

View Source
var (
	// ErrInfoSchemaExpired returns the error that information schema is out of date.
	ErrInfoSchemaExpired = terror.ClassDomain.New(codeInfoSchemaExpired, "Information schema is out of date.")
	// ErrInfoSchemaChanged returns the error that information schema is changed.
	ErrInfoSchemaChanged = terror.ClassDomain.New(codeInfoSchemaChanged, "Information schema is changed.")
)
View Source
var RunAutoAnalyze = true

RunAutoAnalyze indicates if this TiDB server starts auto analyze worker and can run auto analyze job.

Functions

func BindDomain

func BindDomain(ctx sessionctx.Context, domain *Domain)

BindDomain binds domain to context.

Types

type Domain

type Domain struct {
	SchemaValidator SchemaValidator

	MockReloadFailed MockFailure // It mocks reload failed.
	// contains filtered or unexported fields
}

Domain represents a storage space. Different domains can use the same database name. Multiple domains can be used in parallel without synchronization.

func GetDomain

func GetDomain(ctx sessionctx.Context) *Domain

GetDomain gets domain from context.

func NewDomain

func NewDomain(store kv.Storage, ddlLease time.Duration, statsLease time.Duration, factory pools.Factory) *Domain

NewDomain creates a new domain. Should not create multiple domains for the same store.

func (*Domain) Close

func (do *Domain) Close()

Close closes the Domain and release its resource.

func (*Domain) CreateStatsHandle

func (do *Domain) CreateStatsHandle(ctx sessionctx.Context)

CreateStatsHandle is used only for test.

func (*Domain) DDL

func (do *Domain) DDL() ddl.DDL

DDL gets DDL from domain.

func (*Domain) GetScope

func (do *Domain) GetScope(status string) variable.ScopeFlag

GetScope gets the status variables scope.

func (*Domain) GetSnapshotInfoSchema

func (do *Domain) GetSnapshotInfoSchema(snapshotTS uint64) (infoschema.InfoSchema, error)

GetSnapshotInfoSchema gets a snapshot information schema.

func (*Domain) InfoSchema

func (do *Domain) InfoSchema() infoschema.InfoSchema

InfoSchema gets information schema from domain.

func (*Domain) Init

func (do *Domain) Init(ddlLease time.Duration, sysFactory func(*Domain) (pools.Resource, error)) error

Init initializes a domain.

func (*Domain) LoadPrivilegeLoop

func (do *Domain) LoadPrivilegeLoop(ctx sessionctx.Context) error

LoadPrivilegeLoop create a goroutine loads privilege tables in a loop, it should be called only once in BootstrapSession.

func (*Domain) NotifyUpdatePrivilege

func (do *Domain) NotifyUpdatePrivilege(ctx sessionctx.Context)

NotifyUpdatePrivilege updates privilege key in etcd, TiDB client that watches the key will get notification.

func (*Domain) PrivilegeHandle

func (do *Domain) PrivilegeHandle() *privileges.Handle

PrivilegeHandle returns the MySQLPrivilege.

func (*Domain) Reload

func (do *Domain) Reload() error

Reload reloads InfoSchema. It's public in order to do the test.

func (*Domain) SetStatsUpdating

func (do *Domain) SetStatsUpdating(val bool)

SetStatsUpdating sets the value of stats updating.

func (*Domain) StatsHandle

func (do *Domain) StatsHandle() *statistics.Handle

StatsHandle returns the statistic handle.

func (*Domain) StatsUpdating

func (do *Domain) StatsUpdating() bool

StatsUpdating checks if the stats worker is updating.

func (*Domain) Store

func (do *Domain) Store() kv.Storage

Store gets KV store from domain.

func (*Domain) SysSessionPool

func (do *Domain) SysSessionPool() *SessionPool

SysSessionPool returns the system session pool.

func (*Domain) UpdateTableStatsLoop

func (do *Domain) UpdateTableStatsLoop(ctx sessionctx.Context) error

UpdateTableStatsLoop creates a goroutine loads stats info and updates stats info in a loop. It will also start a goroutine to analyze tables automatically. It should be called only once in BootstrapSession.

type EtcdBackend

type EtcdBackend interface {
	EtcdAddrs() []string
	TLSConfig() *tls.Config
	StartGCWorker() error
}

EtcdBackend is used for judging a storage is a real TiKV.

type MockFailure

type MockFailure struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MockFailure mocks reload failed. It's used for fixing data race in tests.

func (*MockFailure) SetValue

func (m *MockFailure) SetValue(isFailed bool)

SetValue sets whether we need to mock reload failed.

type SchemaValidator

type SchemaValidator interface {
	// Update the schema validator, add a new item, delete the expired deltaSchemaInfos.
	// The latest schemaVer is valid within leaseGrantTime plus lease duration.
	// Add the changed table IDs to the new schema information,
	// which is produced when the oldSchemaVer is updated to the newSchemaVer.
	Update(leaseGrantTime uint64, oldSchemaVer, newSchemaVer int64, changedTableIDs []int64)
	// Check is it valid for a transaction to use schemaVer and related tables, at timestamp txnTS.
	Check(txnTS uint64, schemaVer int64, relatedTableIDs []int64) checkResult
	// Stop stops checking the valid of transaction.
	Stop()
	// Restart restarts the schema validator after it is stopped.
	Restart()
	// Reset resets SchemaValidator to initial state.
	Reset()
	// IsStarted indicates whether SchemaValidator is started.
	IsStarted() bool
}

SchemaValidator is the interface for checking the validity of schema version.

func NewSchemaValidator

func NewSchemaValidator(lease time.Duration) SchemaValidator

NewSchemaValidator returns a SchemaValidator structure.

type SessionPool

type SessionPool struct {
	// contains filtered or unexported fields
}

SessionPool is a pool of session.

func (*SessionPool) Close

func (p *SessionPool) Close()

Close closes the pool.

func (*SessionPool) Get

func (p *SessionPool) Get() (resource pools.Resource, err error)

Get gets a resource from the pool.

func (*SessionPool) Put

func (p *SessionPool) Put(resource pools.Resource)

Put puts a resource into to pool.

Jump to

Keyboard shortcuts

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