txnif

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTxnWWConflict = moerr.NewTxnWWConflictNoCtx()
)
View Source
var UncommitTS types.TS

Functions

func RegisterCmdFactory

func RegisterCmdFactory(cmdType int16, factory CmdFactory)

func TxnStrState

func TxnStrState(state TxnState) string

Types

type AppendNode

type AppendNode interface {
	MVCCNode
	TxnEntry
	GetStartRow() uint32
	GetMaxRow() uint32
}

type CmdFactory

type CmdFactory func(int16) TxnCmd

func GetCmdFactory

func GetCmdFactory(cmdType int16) (factory CmdFactory)

type CmdType added in v0.6.0

type CmdType uint16
const (
	CmdInvalid CmdType = iota
	CmdPrepare
	CmdCommit
	CmdRollback
	Cmd1PC
	CmdSnapshot
)

type DeleteChain

type DeleteChain interface {
	sync.Locker
	RLock()
	RUnlock()
	RemoveNodeLocked(DeleteNode)

	AddNodeLocked(txn AsyncTxn, deleteType handle.DeleteType) DeleteNode
	AddMergeNode() DeleteNode

	PrepareRangeDelete(start, end uint32, ts types.TS) error
	DepthLocked() int
	CollectDeletesLocked(ts types.TS, collectIndex bool, rwlocker *sync.RWMutex) (DeleteNode, error)
}

type DeleteNode

type DeleteNode interface {
	MVCCNode
	TxnEntry
	StringLocked() string
	GetChain() DeleteChain
	DeletedRows() []uint32
	RangeDeleteLocked(start, end uint32)
	GetCardinalityLocked() uint32
	IsDeletedLocked(row uint32) bool
	GetRowMaskRefLocked() *roaring.Bitmap
	OnApply() error
}

type MVCCNode added in v0.6.0

type MVCCNode interface {
	String() string

	IsVisible(ts types.TS) (visible bool)
	CheckConflict(ts types.TS) error
	Update(o MVCCNode)

	PreparedIn(minTS, maxTS types.TS) (in, before bool)
	CommittedIn(minTS, maxTS types.TS) (in, before bool)
	NeedWaitCommitting(ts types.TS) (bool, TxnReader)
	IsSameTxn(ts types.TS) bool
	IsActive() bool
	IsCommitting() bool
	IsCommitted() bool
	IsAborted() bool
	Set1PC()
	Is1PC() bool

	GetEnd() types.TS
	GetStart() types.TS
	GetPrepare() types.TS
	GetTxn() TxnReader
	SetLogIndex(idx *wal.Index)
	GetLogIndex() *wal.Index

	ApplyCommit(index *wal.Index) (err error)
	ApplyRollback(index *wal.Index) (err error)
	PrepareCommit() (err error)
	PrepareRollback() (err error)

	WriteTo(w io.Writer) (n int64, err error)
	ReadFrom(r io.Reader) (n int64, err error)
	CloneData() MVCCNode
	CloneAll() MVCCNode

	Close()
}

type Txn2PC

type Txn2PC interface {
	PrepareRollback() error
	ApplyRollback() error
	PrePrepare() error
	PrepareCommit() error
	PreApplyCommit() error
	ApplyCommit() error
}

type TxnAsyncer

type TxnAsyncer interface {
	WaitDone(error, bool) error
	WaitPrepared() error
}

type TxnChanger

type TxnChanger interface {
	sync.Locker
	RLock()
	RUnlock()
	ToCommittedLocked() error
	ToPreparingLocked(ts types.TS) error
	ToPrepared() error
	ToPreparedLocked() error
	ToRollbackedLocked() error

	ToRollbacking(ts types.TS) error
	ToRollbackingLocked(ts types.TS) error
	ToUnknownLocked()
	Prepare() (types.TS, error)
	Committing() error
	Commit() error
	Rollback() error
	SetCommitTS(cts types.TS) error
	SetParticipants(ids []uint64) error
	SetError(error)

	CommittingInRecovery() error
	CommitInRecovery() error
}

type TxnCmd

type TxnCmd interface {
	WriteTo(io.Writer) (int64, error)
	ReadFrom(io.Reader) (int64, error)
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
	GetType() int16
	Desc() string
	String() string
	ApplyRollback()
	ApplyCommit()
	SetReplayTxn(AsyncTxn)
	VerboseString() string
	Close()
}

type TxnEntry

type TxnEntry interface {
	PrepareCommit() error
	PrepareRollback() error
	ApplyCommit(index *wal.Index) error
	ApplyRollback(index *wal.Index) error
	MakeCommand(uint32) (TxnCmd, error)
	Is1PC() bool
	Set1PC()
}

type TxnEntryType

type TxnEntryType int16

type TxnHandle

type TxnHandle interface {
	BindAccessInfo(tenantID, userID, roleID uint32)
	GetTenantID() uint32
	GetUserAndRoleID() (uint32, uint32)
	CreateDatabase(name, createSql string) (handle.Database, error)
	CreateDatabaseWithID(name, createSql string, id uint64) (handle.Database, error)
	DropDatabase(name string) (handle.Database, error)
	DropDatabaseByID(id uint64) (handle.Database, error)
	GetDatabase(name string) (handle.Database, error)
	GetDatabaseByID(id uint64) (handle.Database, error)
	DatabaseNames() []string
}

type TxnMemo added in v0.6.0

type TxnMemo struct {
	*common.Tree
	// contains filtered or unexported fields
}

func NewTxnMemo added in v0.6.0

func NewTxnMemo() *TxnMemo

func (*TxnMemo) AddCatalogChange added in v0.6.0

func (memo *TxnMemo) AddCatalogChange()

func (*TxnMemo) GetDirty added in v0.6.0

func (memo *TxnMemo) GetDirty() *common.Tree

func (*TxnMemo) GetDirtyTableByID added in v0.6.0

func (memo *TxnMemo) GetDirtyTableByID(id uint64) *common.TableTree

func (*TxnMemo) HasAnyTableDataChanges added in v0.6.0

func (memo *TxnMemo) HasAnyTableDataChanges() bool

func (*TxnMemo) HasCatalogChanges added in v0.6.0

func (memo *TxnMemo) HasCatalogChanges() bool

func (*TxnMemo) HasTableDataChanges added in v0.6.0

func (memo *TxnMemo) HasTableDataChanges(id uint64) bool

func (*TxnMemo) ReadFrom added in v0.6.0

func (memo *TxnMemo) ReadFrom(r io.Reader) (n int64, err error)

func (*TxnMemo) WriteTo added in v0.6.0

func (memo *TxnMemo) WriteTo(w io.Writer) (n int64, err error)

type TxnReader

type TxnReader interface {
	RLock()
	RUnlock()
	IsReplay() bool
	Is2PC() bool
	GetID() string
	GetCtx() []byte
	GetStartTS() types.TS
	GetCommitTS() types.TS
	GetPrepareTS() types.TS
	GetParticipants() []uint64
	GetInfo() []byte
	IsVisible(o TxnReader) bool
	GetTxnState(waitIfcommitting bool) TxnState
	GetError() error
	GetStore() TxnStore
	String() string
	Repr() string
	GetLSN() uint64
	GetMemo() *TxnMemo

	SameTxn(startTs types.TS) bool
	CommitBefore(startTs types.TS) bool
	CommitAfter(startTs types.TS) bool
}

type TxnState

type TxnState int32
const (
	TxnStateActive TxnState = iota
	TxnStatePreparing
	//TxnStatePrepared only for 2PC
	TxnStatePrepared
	//TxnStateCommittingFinished only for 2PC txn runs on coordinator
	TxnStateCommittingFinished
	TxnStateRollbacking
	//TxnStateCommitted , TxnStateRollbacked, and TxnStateUnknown are final states.
	TxnStateCommitted
	TxnStateRollbacked
	TxnStateUnknown
)

type TxnStatus added in v0.6.0

type TxnStatus int32

type TxnStore

type TxnStore interface {
	io.Closer
	Txn2PC
	TxnUnsafe
	WaitPrepared() error
	BindTxn(AsyncTxn)
	GetLSN() uint64

	BatchDedup(dbId, id uint64, pk containers.Vector) error
	LogSegmentID(dbId, tid, sid uint64)
	LogBlockID(dbId, tid, bid uint64)

	Append(dbId, id uint64, data *containers.Batch) error
	AddBlksWithMetaLoc(dbId, id uint64,
		pkVecs []containers.Vector,
		file string, metaLocs []string, flag int32) error

	RangeDelete(dbId uint64, id *common.ID, start, end uint32, dt handle.DeleteType) error
	GetByFilter(dbId uint64, id uint64, filter *handle.Filter) (*common.ID, uint32, error)
	GetValue(dbId uint64, id *common.ID, row uint32, col uint16) (any, error)

	CreateRelation(dbId uint64, def any) (handle.Relation, error)
	CreateRelationWithTableId(dbId uint64, tableId uint64, def any) (handle.Relation, error)
	DropRelationByName(dbId uint64, name string) (handle.Relation, error)
	DropRelationByID(dbId uint64, tid uint64) (handle.Relation, error)
	GetRelationByName(dbId uint64, name string) (handle.Relation, error)
	GetRelationByID(dbId uint64, tid uint64) (handle.Relation, error)

	CreateDatabase(name, createSql string) (handle.Database, error)
	CreateDatabaseWithID(name, createSql string, id uint64) (handle.Database, error)
	GetDatabase(name string) (handle.Database, error)
	GetDatabaseByID(id uint64) (handle.Database, error)
	DropDatabase(name string) (handle.Database, error)
	DropDatabaseByID(id uint64) (handle.Database, error)
	DatabaseNames() []string

	GetSegment(dbId uint64, id *common.ID) (handle.Segment, error)
	CreateSegment(dbId, tid uint64, is1PC bool) (handle.Segment, error)
	CreateNonAppendableSegment(dbId, tid uint64, is1PC bool) (handle.Segment, error)
	CreateBlock(dbId, tid, sid uint64, is1PC bool) (handle.Block, error)
	GetBlock(dbId uint64, id *common.ID) (handle.Block, error)
	CreateNonAppendableBlock(dbId uint64, id *common.ID) (handle.Block, error)
	CreateNonAppendableBlockWithMeta(dbId uint64, id *common.ID, metaLoc string, deltaLoc string) (handle.Block, error)
	SoftDeleteSegment(dbId uint64, id *common.ID) error
	SoftDeleteBlock(dbId uint64, id *common.ID) error
	UpdateMetaLoc(dbId uint64, id *common.ID, metaLoc string) (err error)
	UpdateDeltaLoc(dbId uint64, id *common.ID, deltaLoc string) (err error)

	AddTxnEntry(TxnEntryType, TxnEntry)

	LogTxnEntry(dbId, tableId uint64, entry TxnEntry, readed []*common.ID) error
	LogTxnState(sync bool) (entry.Entry, error)

	IsReadonly() bool
	IncreateWriteCnt() int
}

type TxnTest

type TxnTest interface {
	MockIncWriteCnt() int
	SetPrepareCommitFn(func(AsyncTxn) error)
	SetPrepareRollbackFn(func(AsyncTxn) error)
	SetApplyCommitFn(func(AsyncTxn) error)
	SetApplyRollbackFn(func(AsyncTxn) error)
}

type TxnUnsafe added in v0.6.0

type TxnUnsafe interface {
	UnsafeGetDatabase(id uint64) (h handle.Database, err error)
	UnsafeGetRelation(dbId, tableId uint64) (h handle.Relation, err error)
}

type TxnWriter

type TxnWriter interface {
	LogTxnEntry(dbId, tableId uint64, entry TxnEntry, readed []*common.ID) error
	LogTxnState(sync bool) (entry.Entry, error)
}

Jump to

Keyboard shortcuts

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