isolation

package
v1.1.0-beta.0...-5ac0b2e Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 32 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 any) (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) 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) OnPessimisticStmtEnd

func (p *OptimisticTxnContextProvider) 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 (*OptimisticTxnContextProvider) OnPessimisticStmtStart

func (p *OptimisticTxnContextProvider) 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 (*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(ctx context.Context, 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) SetOptionsBeforeCommit

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

func (*OptimisticTxnContextProvider) SetOptionsOnTxnActive

func (p *OptimisticTxnContextProvider) SetOptionsOnTxnActive(txn kv.Transaction)

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 any) (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) OnPessimisticStmtEnd

func (p *PessimisticRCTxnContextProvider) OnPessimisticStmtEnd(ctx context.Context, isSuccessful bool) error

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

func (*PessimisticRCTxnContextProvider) OnPessimisticStmtStart

func (p *PessimisticRCTxnContextProvider) OnPessimisticStmtStart(ctx 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 (*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) 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 any) (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) OnPessimisticStmtEnd

func (p *PessimisticRRTxnContextProvider) OnPessimisticStmtEnd(ctx context.Context, isSuccessful bool) error

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

func (*PessimisticRRTxnContextProvider) OnPessimisticStmtStart

func (p *PessimisticRRTxnContextProvider) OnPessimisticStmtStart(ctx 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 (*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) 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) ActivateTxn

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

ActivateTxn activates the transaction and set the relevant context variables.

func (*PessimisticSerializableTxnContextProvider) AdviseOptimizeWithPlan

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

AdviseOptimizeWithPlan providers optimization according to the plan

func (*PessimisticSerializableTxnContextProvider) AdviseWarmup

func (p *PessimisticSerializableTxnContextProvider) AdviseWarmup() error

AdviseWarmup provides warmup for inner state

func (*PessimisticSerializableTxnContextProvider) GetReadReplicaScope

func (p *PessimisticSerializableTxnContextProvider) GetReadReplicaScope() string

GetReadReplicaScope returns the read replica scope

func (*PessimisticSerializableTxnContextProvider) GetSnapshotWithStmtForUpdateTS

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

GetSnapshotWithStmtForUpdateTS gets snapshot with for update ts

func (*PessimisticSerializableTxnContextProvider) GetSnapshotWithStmtReadTS

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

GetSnapshotWithStmtReadTS gets snapshot with read ts

func (*PessimisticSerializableTxnContextProvider) GetStmtForUpdateTS

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

GetStmtForUpdateTS returns the read timestamp used by update/insert/delete or select ... for update

func (*PessimisticSerializableTxnContextProvider) GetStmtReadTS

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

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

func (*PessimisticSerializableTxnContextProvider) GetTxnInfoSchema

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

GetTxnInfoSchema returns the information schema used by txn

func (*PessimisticSerializableTxnContextProvider) GetTxnScope

func (p *PessimisticSerializableTxnContextProvider) GetTxnScope() string

GetTxnScope returns the current txn scope

func (*PessimisticSerializableTxnContextProvider) OnInitialize

func (p *PessimisticSerializableTxnContextProvider) 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 (*PessimisticSerializableTxnContextProvider) OnLocalTemporaryTableCreated

func (p *PessimisticSerializableTxnContextProvider) OnLocalTemporaryTableCreated()

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

func (*PessimisticSerializableTxnContextProvider) OnPessimisticStmtEnd

func (p *PessimisticSerializableTxnContextProvider) 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 (*PessimisticSerializableTxnContextProvider) OnPessimisticStmtStart

func (p *PessimisticSerializableTxnContextProvider) 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 (*PessimisticSerializableTxnContextProvider) OnStmtCommit

func (p *PessimisticSerializableTxnContextProvider) OnStmtCommit(_ 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(_ context.Context, _ bool) error

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

func (*PessimisticSerializableTxnContextProvider) OnStmtStart

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

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

func (*PessimisticSerializableTxnContextProvider) SetOptionsBeforeCommit

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

func (*PessimisticSerializableTxnContextProvider) SetOptionsOnTxnActive

func (p *PessimisticSerializableTxnContextProvider) SetOptionsOnTxnActive(txn kv.Transaction)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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