txninfo

package
v1.1.0-beta.0...-0c22a2d Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// IDStr is the column name of the TIDB_TRX table's ID column.
	IDStr = "ID"
	// StartTimeStr is the column name of the TIDB_TRX table's StartTime column.
	StartTimeStr = "START_TIME"
	// CurrentSQLDigestStr is the column name of the TIDB_TRX table's CurrentSQLDigest column.
	CurrentSQLDigestStr = "CURRENT_SQL_DIGEST"
	// CurrentSQLDigestTextStr is the column name of the TIDB_TRX table's CurrentSQLDigestText column.
	CurrentSQLDigestTextStr = "CURRENT_SQL_DIGEST_TEXT"
	// StateStr is the column name of the TIDB_TRX table's State column.
	StateStr = "STATE"
	// WaitingStartTimeStr is the column name of the TIDB_TRX table's WaitingStartTime column.
	WaitingStartTimeStr = "WAITING_START_TIME"
	// MemBufferKeysStr is the column name of the TIDB_TRX table's MemBufferKeys column.
	MemBufferKeysStr = "MEM_BUFFER_KEYS"
	// MemBufferBytesStr is the column name of the TIDB_TRX table's MemBufferBytes column.
	MemBufferBytesStr = "MEM_BUFFER_BYTES"
	// SessionIDStr is the column name of the TIDB_TRX table's SessionID column.
	SessionIDStr = "SESSION_ID"
	// UserStr is the column name of the TIDB_TRX table's User column.
	UserStr = "USER"
	// DBStr is the column name of the TIDB_TRX table's DB column.
	DBStr = "DB"
	// AllSQLDigestsStr is the column name of the TIDB_TRX table's AllSQLDigests column.
	AllSQLDigestsStr = "ALL_SQL_DIGESTS"
	// RelatedTableIDsStr is the table id of the TIDB_TRX table's RelatedTableIDs column.
	RelatedTableIDsStr = "RELATED_TABLE_IDS"
	// WaitingTimeStr is the column name of the TIDB_TRX table's WaitingTime column.
	WaitingTimeStr = "WAITING_TIME"
)

Variables

View Source
var Recorder = newTrxHistoryRecorder(0)

Recorder is the recorder instance.

View Source
var TxnRunningStateStrs = []string{
	"Idle", "Running", "LockWaiting", "Committing", "RollingBack",
}

TxnRunningStateStrs is the names of the TxnRunningStates

Functions

func InitMetricsVars

func InitMetricsVars()

InitMetricsVars init transaction metrics vars.

func TxnDurationHistogram

func TxnDurationHistogram(state TxnRunningState, hasLock bool) prometheus.Observer

TxnDurationHistogram returns the observer for the given state and hasLock type.

func TxnStatusEnteringCounter

func TxnStatusEnteringCounter(state TxnRunningState) prometheus.Counter

TxnStatusEnteringCounter returns the counter for the given state.

Types

type ProcessInfo

type ProcessInfo struct {
	// Which session this transaction belongs to
	ConnectionID uint64
	// The user who open this session
	Username string
	// The schema this transaction works on
	CurrentDB string
	// The related table IDs.
	RelatedTableIDs map[int64]struct{}
}

ProcessInfo is part of fields of txnInfo, which will be filled in `session` instead of `LazyTxn`

type TrxHistoryRecorder

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

TrxHistoryRecorder is a history recorder for transaction.

func (*TrxHistoryRecorder) Clean

func (recorder *TrxHistoryRecorder) Clean()

Clean clears the history recorder. For test only.

func (*TrxHistoryRecorder) DumpTrxSummary

func (recorder *TrxHistoryRecorder) DumpTrxSummary() [][]types.Datum

DumpTrxSummary dumps the transaction summary to Datum for displaying in `TRX_SUMMARY` table.

func (*TrxHistoryRecorder) OnTrxEnd

func (recorder *TrxHistoryRecorder) OnTrxEnd(info *TxnInfo)

OnTrxEnd should be called when a transaction ends, ie. leaves `TIDB_TRX` table.

func (*TrxHistoryRecorder) ResizeSummaries

func (recorder *TrxHistoryRecorder) ResizeSummaries(capacity uint)

ResizeSummaries resizes the summaries capacity.

func (*TrxHistoryRecorder) SetMinDuration

func (recorder *TrxHistoryRecorder) SetMinDuration(d time.Duration)

SetMinDuration sets the minimum duration for a transaction to be recorded.

type TxnInfo

type TxnInfo struct {
	StartTS uint64
	// Digest of SQL currently running
	CurrentSQLDigest string
	// Digests of all SQLs executed in the transaction.
	AllSQLDigests []string

	// Current execution state of the transaction.
	State TxnRunningState
	// When last time `State` changes, for metrics
	LastStateChangeTime time.Time
	// Last trying to block start time. Invalid if State is not TxnLockAcquiring.
	BlockStartTime struct {
		Valid bool
		time.Time
	}
	// How many entries are in MemDB
	EntriesCount uint64

	// The following field will be filled in `session` instead of `LazyTxn`
	ProcessInfo *ProcessInfo
}

TxnInfo is information about a running transaction This is supposed to be the datasource of `TIDB_TRX` in infoschema

func (*TxnInfo) ToDatum

func (info *TxnInfo) ToDatum(column string) types.Datum

ToDatum Converts the `TxnInfo`'s specified column to `Datum` to show in the `TIDB_TRX` table.

type TxnRunningState

type TxnRunningState = int32

TxnRunningState is the current state of a transaction

const (
	// TxnIdle means the transaction is idle, i.e. waiting for the user's next statement
	TxnIdle TxnRunningState = iota
	// TxnRunning means the transaction is running, i.e. executing a statement
	TxnRunning
	// TxnLockAcquiring means the transaction is trying to acquire a lock
	TxnLockAcquiring
	// TxnCommitting means“ the transaction is (at least trying to) committing
	TxnCommitting
	// TxnRollingBack means the transaction is rolling back
	TxnRollingBack
	// TxnStateCounter is a marker of the number of states, ensuring we don't miss any of them
	TxnStateCounter
)

Jump to

Keyboard shortcuts

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