lockop

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 28 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,
	vec *vector.Vector,
	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,
	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 UnlockWithUniqueID added in v1.0.0

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

UnlockWithUniqueID unlock all locks by uniqueID

Types

type Argument

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

Argument lock op argument.

func NewArgument

func NewArgument() *Argument

func NewArgumentByEngine added in v1.2.0

func NewArgumentByEngine(engine engine.Engine) *Argument

NewArgument create new lock op argument.

func (*Argument) AddLockTarget

func (arg *Argument) AddLockTarget(
	tableID uint64,
	primaryColumnIndexInBatch int32,
	primaryColumnType types.Type,
	refreshTimestampIndexInBatch int32) *Argument

AddLockTarget add lock target, LockMode_Exclusive will used

func (*Argument) AddLockTargetWithMode added in v1.0.0

func (arg *Argument) AddLockTargetWithMode(
	tableID uint64,
	mode lock.LockMode,
	primaryColumnIndexInBatch int32,
	primaryColumnType types.Type,
	refreshTimestampIndexInBatch int32) *Argument

AddLockTargetWithMode add lock target with lock mode

func (*Argument) AddLockTargetWithPartition

func (arg *Argument) AddLockTargetWithPartition(
	tableIDs []uint64,
	primaryColumnIndexInBatch int32,
	primaryColumnType types.Type,
	refreshTimestampIndexInBatch int32,
	partitionTableIDMappingInBatch int32) *Argument

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 (*Argument) AddLockTargetWithPartitionAndMode added in v1.0.0

func (arg *Argument) AddLockTargetWithPartitionAndMode(
	tableIDs []uint64,
	mode lock.LockMode,
	primaryColumnIndexInBatch int32,
	primaryColumnType types.Type,
	refreshTimestampIndexInBatch int32,
	partitionTableIDMappingInBatch int32) *Argument

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

func (*Argument) Block

func (arg *Argument) Block() bool

Block return if lock operator is a blocked node.

func (*Argument) Call added in v1.1.0

func (arg *Argument) 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 (*Argument) CopyToPipelineTarget

func (arg *Argument) CopyToPipelineTarget() []*pipeline.LockTarget

AddLockTarget add lock targets

func (*Argument) Free

func (arg *Argument) Free(proc *process.Process, pipelineFailed bool, err error)

Free free mem

func (*Argument) GetOperatorBase added in v1.2.0

func (arg *Argument) GetOperatorBase() *vm.OperatorBase

func (*Argument) LockTable

func (arg *Argument) LockTable(
	tableID uint64,
	changeDef bool) *Argument

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

func (*Argument) LockTableWithMode added in v1.0.0

func (arg *Argument) LockTableWithMode(
	tableID uint64,
	mode lock.LockMode,
	changeDef bool) *Argument

LockTableWithMode is similar to LockTable, but with specify lock mode

func (*Argument) Prepare added in v1.1.0

func (arg *Argument) Prepare(proc *process.Process) error

func (*Argument) Release added in v1.2.0

func (arg *Argument) Release()

func (*Argument) SetBlock

func (arg *Argument) SetBlock(block bool) *Argument

SetBlock set the lock op is blocked. If true lock op will block the current pipeline, and cache all input batches. And wait for all the input's batch to be locked before outputting the cached batch to the downstream operator. E.g. select for update, only we get all lock result, then select can be performed, otherwise, if we need retry in RC mode, we may get wrong result.

func (*Argument) String added in v1.1.0

func (arg *Argument) String(buf *bytes.Buffer)

func (Argument) TypeName added in v1.2.0

func (arg Argument) TypeName() string

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 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