lockop

package
v0.0.0-debug-20260702 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LockRows

func LockRows(
	eng engine.Engine,
	proc *process.Process,
	rel engine.Relation,
	tableID uint64,
	bat *batch.Batch,
	idx int32,
	pkType types.Type,
	lockMode lock.LockMode,
	sharding lock.Sharding,
	group uint32,
) error

LockRow lock rows in table, rows will be locked, and wait current txn closed.

func LockTable

func LockTable(
	eng engine.Engine,
	proc *process.Process,
	tableID uint64,
	pkType types.Type,
	changeDef bool) error

LockTable lock table, all rows in the table will be locked, and wait current txn closed.

func LockTableWithUniqueID added in v1.0.0

func LockTableWithUniqueID(
	ctx context.Context,
	sid string,
	uniqueID string,
	tableID uint64,
	txnClient client.TxnClient,
	pkType types.Type,
	eng engine.Engine,
	mp *mpool.MPool,
	mode lock.LockMode,
) error

LockTableWithUniqueID is similar to LockTable, but used to lock a table directly based on a unique identifier, without using an external transaction.

func LockWithMayUpgrade

func LockWithMayUpgrade(
	ctx context.Context,
	lockService lockservice.LockService,
	tableID uint64,
	rows [][]byte,
	txnID []byte,
	options lock.LockOptions,
	fetchFunc FetchLockRowsFunc,
	vec *vector.Vector,
	opts LockOptions,
	pkType types.Type,
) (lock.Result, error)

func UnlockWithUniqueID added in v1.0.0

func UnlockWithUniqueID(
	ctx context.Context,
	uniqueID string) error

UnlockWithUniqueID unlock all locks by uniqueID

Types

type FetchLockRowsFunc

type FetchLockRowsFunc func(

	vec *vector.Vector,

	parker *types.Packer,

	tp types.Type,

	max int,

	lockTable bool,

	filter RowsFilter,

	filterCols []int32) (bool, [][]byte, lock.Granularity)

FetchLockRowsFunc fetch lock rows from vector.

func GetFetchRowsFunc

func GetFetchRowsFunc(t types.Type) FetchLockRowsFunc

GetFetchRowsFunc get FetchLockRowsFunc based on primary key type

type LockOp

type LockOp struct {
	vm.OperatorBase
	// contains filtered or unexported fields
}

LockOp lock op argument.

func NewArgument

func NewArgument() *LockOp

func NewArgumentByEngine added in v1.2.0

func NewArgumentByEngine(engine engine.Engine) *LockOp

NewArgument create new lock op argument.

func (*LockOp) AddLockTarget

func (lockOp *LockOp) AddLockTarget(
	tableID uint64,
	objRef *plan.ObjectRef,
	primaryColumnIndexInBatch int32,
	primaryColumnType types.Type,
	partitionColIndexInBatch int32,
	refreshTimestampIndexInBatch int32,
	lockRows *plan.Expr,
	lockTableAtTheEnd bool) *LockOp

AddLockTarget add lock target, LockMode_Exclusive will used

func (*LockOp) AddLockTargetWithMode

func (lockOp *LockOp) AddLockTargetWithMode(
	tableID uint64,
	objRef *plan.ObjectRef,
	mode lock.LockMode,
	primaryColumnIndexInBatch int32,
	primaryColumnType types.Type,
	partitionColIndexInBatch int32,
	refreshTimestampIndexInBatch int32,
	lockRows *plan.Expr,
	lockTableAtTheEnd bool) *LockOp

AddLockTargetWithMode add lock target with lock mode

func (*LockOp) AddLockTargetWithPartition

func (lockOp *LockOp) AddLockTargetWithPartition(
	tableIDs []uint64,
	primaryColumnIndexInBatch int32,
	primaryColumnType types.Type,
	refreshTimestampIndexInBatch int32,
	lockRows *plan.Expr,
	lockTableAtTheEnd bool,
	partitionTableIDMappingInBatch int32) *LockOp

AddLockTargetWithPartition add lock targets for partition tables. Our partitioned table implementation has each partition as a separate table. So when modifying data, these rows may belong to different partitions. For lock op does not care about the logic of data and partition mapping calculation, the caller needs to tell the lock op.

tableIDs: the set of ids of the sub-tables of the partition to which the data of the current operation is attributed after calculation.

partitionTableIDMappingInBatch: the ID index of the sub-table corresponding to the data. Index of tableIDs

func (*LockOp) AddLockTargetWithPartitionAndMode

func (lockOp *LockOp) AddLockTargetWithPartitionAndMode(
	tableIDs []uint64,
	mode lock.LockMode,
	primaryColumnIndexInBatch int32,
	primaryColumnType types.Type,
	refreshTimestampIndexInBatch int32,
	lockRows *plan.Expr,
	lockTableAtTheEnd bool,
	partitionTableIDMappingInBatch int32) *LockOp

AddLockTargetWithPartitionAndMode is similar to AddLockTargetWithPartition, but you can specify the lock mode

func (*LockOp) Call

func (lockOp *LockOp) Call(proc *process.Process) (vm.CallResult, error)

Call the lock op is used to add locks into lockservice of the Table operated by the current transaction under a pessimistic transaction.

In RC's transaction mode, after successful locking, if an accessed data is found to be concurrently modified by other transactions, a Timestamp column will be put on the output vectors for querying the latest data, and subsequent op needs to check this column to check whether the latest data needs to be read.

func (*LockOp) CopyTargetsFrom

func (lockOp *LockOp) CopyTargetsFrom(src *LockOp)

CopyTargetsFrom creates a deep copy of targets from another LockOp. This is used by dupOperator to avoid sharing targets slice during parallel execution.

func (*LockOp) CopyToPipelineTarget

func (lockOp *LockOp) CopyToPipelineTarget() []*pipeline.LockTarget

AddLockTarget add lock targets

func (*LockOp) ExecProjection

func (lockOp *LockOp) ExecProjection(proc *process.Process, input *batch.Batch) (*batch.Batch, error)

func (*LockOp) Free

func (lockOp *LockOp) Free(proc *process.Process, pipelineFailed bool, err error)

Free free mem

func (*LockOp) GetLockRowsExpressions

func (lockOp *LockOp) GetLockRowsExpressions() []*plan.Expr

func (*LockOp) GetOperatorBase

func (lockOp *LockOp) GetOperatorBase() *vm.OperatorBase

func (*LockOp) LockTable

func (lockOp *LockOp) LockTable(
	tableID uint64,
	changeDef bool) *LockOp

LockTable lock all table, used for delete, truncate and drop table

func (*LockOp) LockTableWithMode

func (lockOp *LockOp) LockTableWithMode(
	tableID uint64,
	mode lock.LockMode,
	changeDef bool) *LockOp

LockTableWithMode is similar to LockTable, but with specify lock mode

func (*LockOp) OpType

func (lockOp *LockOp) OpType() vm.OpType

func (*LockOp) Prepare

func (lockOp *LockOp) Prepare(proc *process.Process) error

func (*LockOp) Release

func (lockOp *LockOp) Release()

func (*LockOp) Reset

func (lockOp *LockOp) Reset(proc *process.Process, pipelineFailed bool, err error)

func (*LockOp) RewriteLockRowsExpressions

func (lockOp *LockOp) RewriteLockRowsExpressions(rewrite func(*plan.Expr) (*plan.Expr, bool, error)) (bool, error)

func (*LockOp) String

func (lockOp *LockOp) String(buf *bytes.Buffer)

func (LockOp) TypeName

func (lockOp LockOp) TypeName() string

type LockOptions

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

LockOptions lock operation options

func DefaultLockOptions

func DefaultLockOptions(parker *types.Packer) LockOptions

DefaultLockOptions create a default lock operation. The parker is used to encode primary key into lock row.

func (LockOptions) WithFetchLockRowsFunc

func (opts LockOptions) WithFetchLockRowsFunc(fetchFunc FetchLockRowsFunc) LockOptions

WithFetchLockRowsFunc set the primary key into lock rows conversion function.

func (LockOptions) WithFilterRows

func (opts LockOptions) WithFilterRows(
	filter RowsFilter,
	filterCols []int32) LockOptions

WithFilterRows set filter rows, filterCols used to rowsFilter func

func (LockOptions) WithHasNewVersionInRangeFunc

func (opts LockOptions) WithHasNewVersionInRangeFunc(fn hasNewVersionInRangeFunc) LockOptions

WithHasNewVersionInRangeFunc setup hasNewVersionInRange func

func (LockOptions) WithLockGroup added in v1.1.0

func (opts LockOptions) WithLockGroup(group uint32) LockOptions

WithLockGroup set lock group

func (LockOptions) WithLockMode

func (opts LockOptions) WithLockMode(mode lock.LockMode) LockOptions

WithLockMode set lock mode, Exclusive or Shared

func (LockOptions) WithLockSharding added in v1.1.0

func (opts LockOptions) WithLockSharding(sharding lock.Sharding) LockOptions

WithLockSharding set lock sharding

func (LockOptions) WithLockTable

func (opts LockOptions) WithLockTable(lockTable, changeDef bool) LockOptions

WithLockTable set lock all table

func (LockOptions) WithMaxBytesPerLock

func (opts LockOptions) WithMaxBytesPerLock(maxBytesPerLock int) LockOptions

WithMaxBytesPerLock every lock operation, will add some lock rows into lockservice. If very many rows of data are added at once, this can result in an excessive memory footprint. This value limits the amount of lock memory that can be allocated per lock operation, and if it is exceeded, it will be converted to a range lock.

type RowsFilter

type RowsFilter func(row int, filterCols []int32) bool

RowsFilter used to filter row from primary vector. The row will not lock if filter return false.

Jump to

Keyboard shortcuts

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