staleread

package
v1.1.0-beta.0...-6d74071 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertStmtStaleness

func AssertStmtStaleness(sctx sessionctx.Context, expected bool)

AssertStmtStaleness is used only for test

func CalculateAsOfTsExpr

func CalculateAsOfTsExpr(ctx context.Context, sctx planctx.PlanContext, tsExpr ast.ExprNode) (uint64, error)

CalculateAsOfTsExpr calculates the TsExpr of AsOfClause to get a StartTS.

func CalculateTsWithReadStaleness

func CalculateTsWithReadStaleness(ctx context.Context, sctx sessionctx.Context, readStaleness time.Duration) (uint64, error)

CalculateTsWithReadStaleness calculates the TsExpr for readStaleness duration

func GetExternalTimestamp

func GetExternalTimestamp(ctx context.Context, sc *stmtctx.StatementContext) (uint64, error)

GetExternalTimestamp returns the external timestamp in cache, or get and store it in cache

func GetSessionSnapshotInfoSchema

func GetSessionSnapshotInfoSchema(sctx sessionctx.Context, snapshotTS uint64) (infoschema.InfoSchema, error)

GetSessionSnapshotInfoSchema returns the session's information schema with specified ts

func IsStmtStaleness

func IsStmtStaleness(sctx sessionctx.Context) bool

IsStmtStaleness indicates whether the current statement is staleness or not

Types

type Processor

type Processor interface {
	// IsStaleness indicates that whether we should use the staleness
	IsStaleness() bool
	// GetStalenessInfoSchema returns the information schema if it is stale read, otherwise returns nil
	GetStalenessInfoSchema() infoschema.InfoSchema
	// GetStalenessReadTS returns the ts if it is stale read, otherwise returns 0
	GetStalenessReadTS() uint64
	// GetStalenessTSEvaluatorForPrepare returns a function that will be used by prepare to evaluate ts
	GetStalenessTSEvaluatorForPrepare() StalenessTSEvaluator

	// OnSelectTable will be called when process table in select statement
	OnSelectTable(tn *ast.TableName) error
	// OnExecutePreparedStmt when process execute
	OnExecutePreparedStmt(preparedTSEvaluator StalenessTSEvaluator) error
}

Processor is an interface used to process stale read

func NewStaleReadProcessor

func NewStaleReadProcessor(ctx context.Context, sctx sessionctx.Context) Processor

NewStaleReadProcessor creates a new stale read processor

type StalenessTSEvaluator

type StalenessTSEvaluator func(ctx context.Context, sctx sessionctx.Context) (uint64, error)

StalenessTSEvaluator is a function to get staleness ts

type StalenessTxnContextProvider

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

StalenessTxnContextProvider implements sessiontxn.TxnContextProvider

func NewStalenessTxnContextProvider

func NewStalenessTxnContextProvider(sctx sessionctx.Context, ts uint64, is infoschema.InfoSchema) *StalenessTxnContextProvider

NewStalenessTxnContextProvider creates a new StalenessTxnContextProvider

func (*StalenessTxnContextProvider) ActivateTxn

func (p *StalenessTxnContextProvider) ActivateTxn() (kv.Transaction, error)

ActivateTxn activates the transaction.

func (*StalenessTxnContextProvider) AdviseOptimizeWithPlan

func (p *StalenessTxnContextProvider) AdviseOptimizeWithPlan(_ any) error

AdviseOptimizeWithPlan providers optimization according to the plan

func (*StalenessTxnContextProvider) AdviseWarmup

func (p *StalenessTxnContextProvider) AdviseWarmup() error

AdviseWarmup provides warmup for inner state

func (*StalenessTxnContextProvider) GetReadReplicaScope

func (p *StalenessTxnContextProvider) GetReadReplicaScope() string

GetReadReplicaScope returns the read replica scope

func (*StalenessTxnContextProvider) GetSnapshotWithStmtForUpdateTS

func (p *StalenessTxnContextProvider) GetSnapshotWithStmtForUpdateTS() (kv.Snapshot, error)

GetSnapshotWithStmtForUpdateTS gets snapshot with for update ts

func (*StalenessTxnContextProvider) GetSnapshotWithStmtReadTS

func (p *StalenessTxnContextProvider) GetSnapshotWithStmtReadTS() (kv.Snapshot, error)

GetSnapshotWithStmtReadTS gets snapshot with read ts and set the transaction related options before return

func (*StalenessTxnContextProvider) GetStmtForUpdateTS

func (p *StalenessTxnContextProvider) GetStmtForUpdateTS() (uint64, error)

GetStmtForUpdateTS will return an error because stale read does not support it

func (*StalenessTxnContextProvider) GetStmtReadTS

func (p *StalenessTxnContextProvider) GetStmtReadTS() (uint64, error)

GetStmtReadTS returns the read timestamp

func (*StalenessTxnContextProvider) GetTxnInfoSchema

func (p *StalenessTxnContextProvider) GetTxnInfoSchema() infoschema.InfoSchema

GetTxnInfoSchema returns the information schema used by txn

func (*StalenessTxnContextProvider) GetTxnScope

func (p *StalenessTxnContextProvider) GetTxnScope() string

GetTxnScope returns the current txn scope

func (*StalenessTxnContextProvider) OnInitialize

OnInitialize is the hook that should be called when enter a new txn with this provider

func (*StalenessTxnContextProvider) OnLocalTemporaryTableCreated

func (p *StalenessTxnContextProvider) OnLocalTemporaryTableCreated()

OnLocalTemporaryTableCreated will not be called for StalenessTxnContextProvider

func (*StalenessTxnContextProvider) OnPessimisticStmtEnd

func (p *StalenessTxnContextProvider) OnPessimisticStmtEnd(_ context.Context, _ bool) error

OnPessimisticStmtEnd is the hook that should be called when finishes handling a pessimistic DML or select-for-update statement.

func (*StalenessTxnContextProvider) OnPessimisticStmtStart

func (p *StalenessTxnContextProvider) OnPessimisticStmtStart(_ context.Context) error

OnPessimisticStmtStart is the hook that should be called when starts handling a pessimistic DML or a pessimistic select-for-update statements.

func (*StalenessTxnContextProvider) OnStmtCommit

func (p *StalenessTxnContextProvider) OnStmtCommit(_ context.Context) error

OnStmtCommit is the hook that should be called when a statement is executed successfully.

func (*StalenessTxnContextProvider) OnStmtErrorForNextAction

OnStmtErrorForNextAction is the hook that should be called when a new statement get an error

func (*StalenessTxnContextProvider) OnStmtRetry

func (p *StalenessTxnContextProvider) OnStmtRetry(ctx context.Context) error

OnStmtRetry is the hook that should be called when a statement retry

func (*StalenessTxnContextProvider) OnStmtRollback

func (p *StalenessTxnContextProvider) OnStmtRollback(_ context.Context, _ bool) error

OnStmtRollback is the hook that should be called when a statement fails to execute.

func (*StalenessTxnContextProvider) OnStmtStart

OnStmtStart is the hook that should be called when a new statement starte

func (*StalenessTxnContextProvider) SetOptionsBeforeCommit

func (p *StalenessTxnContextProvider) SetOptionsBeforeCommit(txn kv.Transaction, commitTSChecker func(uint64) bool) error

SetOptionsBeforeCommit sets the options before commit, because stale read txn is read only, no need to set options.

Jump to

Keyboard shortcuts

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