deadlockhistory

package
v1.1.0-beta.0...-9b70321 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ColDeadlockIDStr is the name of the DEADLOCK_ID column in INFORMATION_SCHEMA.DEADLOCKS and INFORMATION_SCHEMA.CLUSTER_DEADLOCKS table.
	ColDeadlockIDStr = "DEADLOCK_ID"
	// ColOccurTimeStr is the name of the OCCUR_TIME column in INFORMATION_SCHEMA.DEADLOCKS and INFORMATION_SCHEMA.CLUSTER_DEADLOCKS table.
	ColOccurTimeStr = "OCCUR_TIME"
	// ColRetryableStr is the name of the RETRYABLE column in INFORMATION_SCHEMA.DEADLOCKS and INFORMATION_SCHEMA.CLUSTER_DEADLOCKS table.
	ColRetryableStr = "RETRYABLE"
	// ColTryLockTrxIDStr is the name of the TRY_LOCK_TRX_ID column in INFORMATION_SCHEMA.DEADLOCKS and INFORMATION_SCHEMA.CLUSTER_DEADLOCKS table.
	ColTryLockTrxIDStr = "TRY_LOCK_TRX_ID"
	// ColCurrentSQLDigestStr is the name of the CURRENT_SQL_DIGEST column in INFORMATION_SCHEMA.DEADLOCKS and INFORMATION_SCHEMA.CLUSTER_DEADLOCKS table.
	ColCurrentSQLDigestStr = "CURRENT_SQL_DIGEST"
	// ColCurrentSQLDigestTextStr is the name of the CURRENT_SQL_DIGEST_TEXT column in INFORMATION_SCHEMA.DEADLOCKS and INFORMATION_SCHEMA.CLUSTER_DEADLOCKS table.
	ColCurrentSQLDigestTextStr = "CURRENT_SQL_DIGEST_TEXT"
	// ColKeyStr is the name of the KEY column in INFORMATION_SCHEMA.DEADLOCKS and INFORMATION_SCHEMA.CLUSTER_DEADLOCKS table.
	ColKeyStr = "KEY"
	// ColKeyInfoStr is the name of the KEY_INFO column in INFORMATION_SCHEMA.DEADLOCKS and INFORMATION_SCHEMA.CLUSTER_DEADLOCKS table.
	ColKeyInfoStr = "KEY_INFO"
	// ColTrxHoldingLockStr is the name of the TRX_HOLDING_LOCK column in INFORMATION_SCHEMA.DEADLOCKS and INFORMATION_SCHEMA.CLUSTER_DEADLOCKS table.
	ColTrxHoldingLockStr = "TRX_HOLDING_LOCK"
)

Variables

View Source
var GlobalDeadlockHistory = NewDeadlockHistory(0)

GlobalDeadlockHistory is the global instance of DeadlockHistory, which is used to maintain recent several recent deadlock events globally. The real size of the deadlock history table should be initialized with `Resize` in `setGlobalVars` in tidb-server/main.go

Functions

This section is empty.

Types

type DeadlockHistory

type DeadlockHistory struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DeadlockHistory is a collection for maintaining recent several deadlock events. All its public APIs are thread safe.

func NewDeadlockHistory

func NewDeadlockHistory(capacity uint) *DeadlockHistory

NewDeadlockHistory creates an instance of DeadlockHistory

func (*DeadlockHistory) Clear

func (d *DeadlockHistory) Clear()

Clear clears content from deadlock histories

func (*DeadlockHistory) GetAll

func (d *DeadlockHistory) GetAll() []*DeadlockRecord

GetAll gets all collected deadlock events.

func (*DeadlockHistory) Push

func (d *DeadlockHistory) Push(record *DeadlockRecord)

Push pushes an element into the queue. It will set the `ID` field of the record, and add the pointer directly to the collection. Be aware that do not modify the record's content after pushing.

func (*DeadlockHistory) Resize

func (d *DeadlockHistory) Resize(newCapacity uint)

Resize update the DeadlockHistory's table max capacity to newCapacity

type DeadlockRecord

type DeadlockRecord struct {
	OccurTime time.Time
	WaitChain []WaitChainItem
	// The ID doesn't need to be set manually and it's set when it's added into the DeadlockHistory by invoking its Push
	// method.
	ID          uint64
	IsRetryable bool
}

DeadlockRecord represents a deadlock events, and contains multiple transactions' information.

func ErrDeadlockToDeadlockRecord

func ErrDeadlockToDeadlockRecord(dl *tikverr.ErrDeadlock) *DeadlockRecord

ErrDeadlockToDeadlockRecord generates a DeadlockRecord from the information in a `tikverr.ErrDeadlock` error.

func (*DeadlockRecord) ToDatum

func (r *DeadlockRecord) ToDatum(waitChainIdx int, columnName string) types.Datum

ToDatum creates the datum for the specified column of `INFORMATION_SCHEMA.DEADLOCKS` table. Usually a single deadlock record generates multiple rows, one for each item in wait chain. The first parameter `waitChainIdx` specifies which wait chain item is to be used.

type WaitChainItem

type WaitChainItem struct {
	SQLDigest      string
	Key            []byte
	AllSQLDigests  []string
	TryLockTxn     uint64
	TxnHoldingLock uint64
}

WaitChainItem represents an entry in a deadlock's wait chain.

Jump to

Keyboard shortcuts

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