transaction

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Like           dBOperation = "LIKE"
	Equal          dBOperation = "="
	NotEqual       dBOperation = "<>"
	LessThan       dBOperation = "<"
	LessEqualThan  dBOperation = "<="
	GreatThan      dBOperation = ">"
	GrateEqualThan dBOperation = ">="
)

Variables

View Source
var (
	ErrorTrxManagerNotInitialize = errors.New("TrxManager not initialize")
	DefaultCleanLogDelay         = 1 * time.Hour
)
View Source
var ErrorInvalidTxId = errors.New("invalid transaction id")

Functions

func CommitXA

func CommitXA(ctx context.Context, bc *mysql.BackendConnection) (proto.Result, error)

CommitXA do commit xa transaction action

func CreateTrxManager

func CreateTrxManager(tenant string) error

CreateTrxManager inits TxFaultDecisionExecutor

func EndXA

EndXA do end xa transaction action

func NewXADeadLockDog

func NewXADeadLockDog() (runtime.DeadLockDog, error)

NewXADeadLockDog creates xa runtime.DeadLockDog

func NewXAHook

func NewXAHook(tenant string, enable bool) (*xaHook, error)

NewXAHook creates new XAHook

func PrepareXA

func PrepareXA(ctx context.Context, bc *mysql.BackendConnection) (proto.Result, error)

PrepareXA do prepare xa transaction action

func RollbackXA

func RollbackXA(ctx context.Context, bc *mysql.BackendConnection) (proto.Result, error)

RollbackXA do rollback xa transaction action

func StartXA

StartXA do start xa transaction action

Types

type Condition

type Condition struct {
	FiledName string
	Operation dBOperation
	Value     interface{}
}

Condition sql query where condition

type TrxLog

type TrxLog struct {
	TrxID        string
	ServerID     int32
	State        runtime.TxState
	Participants []TrxParticipant
	Tenant       string
}

TrxLog arana tx log

type TrxManager

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

func GetTrxManager

func GetTrxManager(tenant string) (*TrxManager, error)

GetTrxManager returns *TrxManager

type TrxParticipant

type TrxParticipant struct {
	NodeID     string
	RemoteAddr string
	Schema     string
}

TrxParticipant join target trx all node info

type TxFaultDecisionExecutor

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

TxFaultDecisionExecutor Decisions of transaction pocket regularly scan the `__arana_tx_log` table to query the list of unfinished transactions case 1: If it is in the prepare state, if it exceeds a certain period of time, the transaction will be rolled back directly case 2: If it is in the Committing state, commit the transaction again and end the current transaction case 3: If it is in Aborting state, roll back the transaction again and end the current transaction important!!! the execution of this task requires distributed task preemption based on the metadata DB

func (*TxFaultDecisionExecutor) Run

func (bm *TxFaultDecisionExecutor) Run()

Run Core logic of the decision -making decision -making at the bottom of the affairs

type TxLogManager

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

TxLogManager Transaction log management

func (*TxLogManager) AddOrUpdateTxLog

func (gm *TxLogManager) AddOrUpdateTxLog(l TrxLog) error

AddOrUpdateTxLog Add or update transaction log

func (*TxLogManager) DeleteTxLog

func (gm *TxLogManager) DeleteTxLog(l TrxLog) error

DeleteTxLog Delete transaction log

func (*TxLogManager) Init

func (gm *TxLogManager) Init(delay time.Duration) error

init executes create __arana_tx_log table action

func (*TxLogManager) ScanTxLog

func (gm *TxLogManager) ScanTxLog(pageNo, pageSize uint64, conditions []Condition) (uint32, []TrxLog, error)

ScanTxLog Scanning transaction

Jump to

Keyboard shortcuts

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