isolation

package
v7.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NeedSetRCCheckTSFlag

func NeedSetRCCheckTSFlag(ctx sessionctx.Context, node ast.Node) bool

NeedSetRCCheckTSFlag checks whether it's needed to set `RCCheckTS` flag in current stmtctx.

Types

type OptimisticTxnContextProvider

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

OptimisticTxnContextProvider provides txn context for optimistic transaction

func (*OptimisticTxnContextProvider) ActivateTxn

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

ActivateTxn activates the transaction and set the relevant context variables.

func (*OptimisticTxnContextProvider) AdviseOptimizeWithPlan

func (p *OptimisticTxnContextProvider) AdviseOptimizeWithPlan(plan interface{}) (err error)

AdviseOptimizeWithPlan providers optimization according to the plan It will use MaxTS as the startTS in autocommit txn for some plans.

func (*OptimisticTxnContextProvider) AdviseWarmup

func (p *OptimisticTxnContextProvider) AdviseWarmup() error

AdviseWarmup provides warmup for inner state

func (*OptimisticTxnContextProvider) GetReadReplicaScope

func (p *OptimisticTxnContextProvider) GetReadReplicaScope() string

GetReadReplicaScope returns the read replica scope

func (*OptimisticTxnContextProvider) GetSnapshotWithStmtForUpdateTS

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

GetSnapshotWithStmtForUpdateTS gets snapshot with for update ts

func (*OptimisticTxnContextProvider) GetSnapshotWithStmtReadTS

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

GetSnapshotWithStmtReadTS gets snapshot with read ts

func (*OptimisticTxnContextProvider) GetStmtForUpdateTS

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

GetStmtForUpdateTS returns the read timestamp used by select statement (not for select ... for update)

func (*OptimisticTxnContextProvider) GetStmtReadTS

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

GetStmtReadTS returns the read timestamp used by select statement (not for select ... for update)

func (*OptimisticTxnContextProvider) GetTxnInfoSchema

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

GetTxnInfoSchema returns the information schema used by txn

func (*OptimisticTxnContextProvider) GetTxnScope

func (p *OptimisticTxnContextProvider) GetTxnScope() string

GetTxnScope returns the current txn scope

func (*OptimisticTxnContextProvider) OnHandlePessimisticStmtStart

func (p *OptimisticTxnContextProvider) OnHandlePessimisticStmtStart(_ context.Context) error

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

func (*OptimisticTxnContextProvider) OnInitialize

func (p *OptimisticTxnContextProvider) OnInitialize(ctx context.Context, tp sessiontxn.EnterNewTxnType) (err error)

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

func (*OptimisticTxnContextProvider) OnLocalTemporaryTableCreated

func (p *OptimisticTxnContextProvider) OnLocalTemporaryTableCreated()

OnLocalTemporaryTableCreated is the hook that should be called when a local temporary table created.

func (*OptimisticTxnContextProvider) OnStmtCommit

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

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

func (*OptimisticTxnContextProvider) OnStmtErrorForNextAction

func (p *OptimisticTxnContextProvider) OnStmtErrorForNextAction(point sessiontxn.StmtErrorHandlePoint, err error) (sessiontxn.StmtErrorAction, error)

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

func (*OptimisticTxnContextProvider) OnStmtRetry

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

OnStmtRetry is the hook that should be called when a statement is retried internally.

func (*OptimisticTxnContextProvider) OnStmtRollback

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

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

func (*OptimisticTxnContextProvider) OnStmtStart

func (p *OptimisticTxnContextProvider) OnStmtStart(ctx context.Context, _ ast.StmtNode) error

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

func (*OptimisticTxnContextProvider) ResetForNewTxn

func (p *OptimisticTxnContextProvider) ResetForNewTxn(sctx sessionctx.Context, causalConsistencyOnly bool)

ResetForNewTxn resets OptimisticTxnContextProvider to an initial state for a new txn

func (*OptimisticTxnContextProvider) SetTxnInfoSchema

func (p *OptimisticTxnContextProvider) SetTxnInfoSchema(is infoschema.InfoSchema)

type PessimisticRCTxnContextProvider

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

PessimisticRCTxnContextProvider provides txn context for isolation level read-committed

func NewPessimisticRCTxnContextProvider

func NewPessimisticRCTxnContextProvider(sctx sessionctx.Context, causalConsistencyOnly bool) *PessimisticRCTxnContextProvider

NewPessimisticRCTxnContextProvider returns a new PessimisticRCTxnContextProvider

func (*PessimisticRCTxnContextProvider) AdviseOptimizeWithPlan

func (p *PessimisticRCTxnContextProvider) AdviseOptimizeWithPlan(val interface{}) (err error)

AdviseOptimizeWithPlan in read-committed covers as many cases as repeatable-read. We do not fetch latest ts immediately for such scenes. 1. A query like the form of "SELECT ... FOR UPDATE" whose execution plan is "PointGet". 2. An INSERT statement without "SELECT" subquery. 3. A UPDATE statement whose sub execution plan is "PointGet". 4. A DELETE statement whose sub execution plan is "PointGet".

func (*PessimisticRCTxnContextProvider) AdviseWarmup

func (p *PessimisticRCTxnContextProvider) AdviseWarmup() error

AdviseWarmup provides warmup for inner state

func (*PessimisticRCTxnContextProvider) GetSnapshotWithStmtForUpdateTS

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

GetSnapshotWithStmtForUpdateTS gets snapshot with for update ts

func (*PessimisticRCTxnContextProvider) GetSnapshotWithStmtReadTS

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

GetSnapshotWithStmtReadTS gets snapshot with read ts

func (*PessimisticRCTxnContextProvider) IsCheckTSInWriteStmtMode

func (p *PessimisticRCTxnContextProvider) IsCheckTSInWriteStmtMode() bool

IsCheckTSInWriteStmtMode is only used for test

func (*PessimisticRCTxnContextProvider) OnHandlePessimisticStmtStart

func (p *PessimisticRCTxnContextProvider) OnHandlePessimisticStmtStart(ctx context.Context) error

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

func (*PessimisticRCTxnContextProvider) OnStmtCommit

func (p *PessimisticRCTxnContextProvider) OnStmtCommit(ctx context.Context) error

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

func (*PessimisticRCTxnContextProvider) OnStmtErrorForNextAction

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

func (*PessimisticRCTxnContextProvider) OnStmtRetry

OnStmtRetry is the hook that should be called when a statement is retried internally.

func (*PessimisticRCTxnContextProvider) OnStmtRollback

func (p *PessimisticRCTxnContextProvider) OnStmtRollback(ctx context.Context, isForPessimisticRetry bool) error

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

func (*PessimisticRCTxnContextProvider) OnStmtStart

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

type PessimisticRRTxnContextProvider

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

PessimisticRRTxnContextProvider provides txn context for isolation level repeatable-read

func NewPessimisticRRTxnContextProvider

func NewPessimisticRRTxnContextProvider(sctx sessionctx.Context, causalConsistencyOnly bool) *PessimisticRRTxnContextProvider

NewPessimisticRRTxnContextProvider returns a new PessimisticRRTxnContextProvider

func (*PessimisticRRTxnContextProvider) AdviseOptimizeWithPlan

func (p *PessimisticRRTxnContextProvider) AdviseOptimizeWithPlan(val interface{}) (err error)

AdviseOptimizeWithPlan optimizes for update point get related execution. Use case: In for update point get related operations, we do not fetch ts from PD but use the last ts we fetched.

We expect that the data that the point get acquires has not been changed.

Benefit: Save the cost of acquiring ts from PD. Drawbacks: If the data has been changed since the ts we used, we need to retry. One exception is insert operation, when it has no select plan, we do not fetch the latest ts immediately. We only update ts if write conflict is incurred.

func (*PessimisticRRTxnContextProvider) OnHandlePessimisticStmtStart

func (p *PessimisticRRTxnContextProvider) OnHandlePessimisticStmtStart(ctx context.Context) error

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

func (*PessimisticRRTxnContextProvider) OnStmtCommit

func (p *PessimisticRRTxnContextProvider) OnStmtCommit(ctx context.Context) error

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

func (*PessimisticRRTxnContextProvider) OnStmtErrorForNextAction

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

func (*PessimisticRRTxnContextProvider) OnStmtRetry

func (p *PessimisticRRTxnContextProvider) OnStmtRetry(ctx context.Context) (err error)

OnStmtRetry is the hook that should be called when a statement is retried internally.

func (*PessimisticRRTxnContextProvider) OnStmtRollback

func (p *PessimisticRRTxnContextProvider) OnStmtRollback(ctx context.Context, isForPessimisticRetry bool) error

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

func (*PessimisticRRTxnContextProvider) OnStmtStart

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

type PessimisticSerializableTxnContextProvider

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

PessimisticSerializableTxnContextProvider provides txn context for isolation level oracle-like serializable

func NewPessimisticSerializableTxnContextProvider

func NewPessimisticSerializableTxnContextProvider(sctx sessionctx.Context,
	causalConsistencyOnly bool) *PessimisticSerializableTxnContextProvider

NewPessimisticSerializableTxnContextProvider returns a new PessimisticSerializableTxnContextProvider

func (*PessimisticSerializableTxnContextProvider) OnHandlePessimisticStmtStart

func (p *PessimisticSerializableTxnContextProvider) OnHandlePessimisticStmtStart(ctx context.Context) error

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

func (*PessimisticSerializableTxnContextProvider) OnStmtCommit

func (p *PessimisticSerializableTxnContextProvider) OnStmtCommit(ctx context.Context) error

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

func (*PessimisticSerializableTxnContextProvider) OnStmtErrorForNextAction

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

func (*PessimisticSerializableTxnContextProvider) OnStmtRetry

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

OnStmtRetry is the hook that should be called when a statement is retried internally.

func (*PessimisticSerializableTxnContextProvider) OnStmtRollback

func (p *PessimisticSerializableTxnContextProvider) OnStmtRollback(ctx context.Context, isForPessimisticRetry bool) error

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

Jump to

Keyboard shortcuts

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