domain

package
v0.0.0-...-3903214 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NewSessionDefaultRetryCnt is the default retry times when create new session.
	NewSessionDefaultRetryCnt = 3
	// NewSessionRetryUnlimited is the unlimited retry times when create new session.
	NewSessionRetryUnlimited = math.MaxInt64
)
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. "+kv.TxnRetryableMark)
)
View Source
var (
	// SchemaOutOfDateRetryInterval is the backoff time before retrying.
	SchemaOutOfDateRetryInterval = int64(500 * time.Millisecond)
	// SchemaOutOfDateRetryTimes is the max retry count when the schema is out of date.
	SchemaOutOfDateRetryTimes = int32(10)
)

Functions

func BindDomain

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

BindDomain binds domain to context.

Types

type Domain

type Domain struct {
	SchemaValidator SchemaValidator
	// 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 Bootstrap

func Bootstrap(store kv.Storage, sessionFactory pools.Factory) (*Domain, error)

func GetDomain

func GetDomain(ctx sessionctx.Context) *Domain

GetDomain gets domain from context.

func GetDomain4Test

func GetDomain4Test() *Domain

func GetOnlyDomain

func GetOnlyDomain() *Domain

func NewDomain

func NewDomain(store kv.Storage, sessionFactory pools.Factory) *Domain

func (*Domain) Close

func (do *Domain) Close()

func (*Domain) DDL

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

func (*Domain) InfoSchema

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

func (*Domain) Init

func (do *Domain) Init(ddlLease time.Duration) error

Init: ddlLease is used for ddl initialization.

func (*Domain) ReloadInfoSchema

func (do *Domain) ReloadInfoSchema() error

func (*Domain) Store

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

func (*Domain) SysSessionPool

func (do *Domain) SysSessionPool() *sessionPool

SysSessionPool returns the system session pool.

type SchemaChecker

type SchemaChecker struct {
	SchemaValidator
	// contains filtered or unexported fields
}

SchemaChecker is used for checking schema-validity.

func NewSchemaChecker

func NewSchemaChecker(do *Domain, schemaVer int64, relatedTableIDs []int64) *SchemaChecker

NewSchemaChecker creates a new schema checker.

func (*SchemaChecker) Check

func (s *SchemaChecker) Check(txnTS uint64) error

Check checks the validity of the schema version.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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