lockwaiter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LockNoWait = int64(-1)

LockNoWait is used for pessimistic lock wait time these two constants are special for lock protocol with tikv -1 means nowait, others meaning lock wait in milliseconds

Functions

This section is empty.

Types

type Manager

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

Manager represents a waiters manager.

func NewManager

func NewManager(conf *config.Config) *Manager

NewManager returns a new manager.

func (*Manager) CleanUp

func (lw *Manager) CleanUp(w *Waiter)

CleanUp removes a waiter from waitingQueues when wait timeout.

func (*Manager) NewWaiter

func (lw *Manager) NewWaiter(startTS, lockTS, keyHash uint64, timeout time.Duration) *Waiter

NewWaiter returns a new waiter.

func (*Manager) WakeUp

func (lw *Manager) WakeUp(txn, commitTS uint64, keyHashes []uint64)

WakeUp wakes up waiters that waiting on the transaction.

func (*Manager) WakeUpForDeadlock

func (lw *Manager) WakeUpForDeadlock(resp *deadlock.DeadlockResponse)

WakeUpForDeadlock wakes up waiters waiting for deadlock detection results

type WaitResult

type WaitResult struct {
	DeadlockResp *deadlock.DeadlockResponse
	// WakeupSleepTime, -1 means the wait is already timeout, 0 means the lock will be granted to this waiter
	// others are the wake-up-delay-duration sleep time, in milliseconds
	WakeupSleepTime WakeupWaitTime
	CommitTS        uint64
}

WaitResult represents a wait result.

type Waiter

type Waiter struct {
	LockTS   uint64
	KeyHash  uint64
	CommitTs uint64
	// contains filtered or unexported fields
}

Waiter represents a waiter.

func (*Waiter) DrainCh

func (w *Waiter) DrainCh()

DrainCh drains channel.

func (*Waiter) Wait

func (w *Waiter) Wait() WaitResult

Wait waits on a lock until waked by others or timeout.

type WakeupWaitTime

type WakeupWaitTime int

WakeupWaitTime is the implementation of variable "wake-up-delay-duration"

const (
	WaitTimeout        WakeupWaitTime = -1
	WakeUpThisWaiter   WakeupWaitTime = 0
	WakeupDelayTimeout WakeupWaitTime = 1
)

WakeupWaitTime

Jump to

Keyboard shortcuts

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