transaction

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EstimatedMaxQPS = 1000000
	TxnPartitionNum = 256
)

Variables

View Source
var HasMoreWritingWriters = NewWriter(types.DBMeta{Flag: consts.ValueMetaBitMaskHasWriteIntent}, newTransaction(types.MaxTxnId, nil, nil))

HasMoreWritingWriters is a dummy writer used to indicate that has more pending writers afterwards, the Next list is not complete

View Source
var InvalidKeyEvent = KeyEvent{Type: KeyEventTypeInvalid}

Functions

This section is empty.

Types

type KeyEvent

type KeyEvent struct {
	Key  string
	Type KeyEventType
}

Deprecated

func NewKeyEvent

func NewKeyEvent(key string, typ KeyEventType) KeyEvent

func (KeyEvent) String

func (e KeyEvent) String() string

type KeyEventType

type KeyEventType int

Deprecated

const (
	// Deprecated
	KeyEventTypeInvalid KeyEventType = iota
	// Deprecated
	KeyEventTypeClearWriteIntent // cleared or clearing
	// Deprecated
	KeyEventTypeVersionRemoved
	// Deprecated
	KeyEventTypeRemoveVersionFailed
)

func (KeyEventType) String

func (t KeyEventType) String() string

type KeyEventWaiter

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

Deprecated

func (*KeyEventWaiter) Wait

func (w *KeyEventWaiter) Wait(ctx context.Context) (KeyEvent, error)

func (*KeyEventWaiter) WaitWithTimeout

func (w *KeyEventWaiter) WaitWithTimeout(ctx context.Context, timeout time.Duration) (KeyEvent, error)

type Manager

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

func NewManager

func NewManager(cfg types.TabletTxnManagerConfig) *Manager

func (*Manager) Close

func (tm *Manager) Close()

func (*Manager) GetTxn

func (tm *Manager) GetTxn(txnId types.TxnId) (*Transaction, error)

func (*Manager) InsertTxnIfNotExists

func (tm *Manager) InsertTxnIfNotExists(id types.TxnId, db types.KV) (inserted bool, txn *Transaction, err error)

func (*Manager) MustInsertTxnIfNotExists

func (tm *Manager) MustInsertTxnIfNotExists(id types.TxnId, db types.KV) (inserted bool, txn *Transaction)

func (*Manager) PushReadModifyWriteReaderOnKey

func (tm *Manager) PushReadModifyWriteReaderOnKey(key string, readOpt types.KVCCReadOption) (*readModifyWriteCond, error)

func (*Manager) SignalReadModifyWriteKeyEvent

func (tm *Manager) SignalReadModifyWriteKeyEvent(readModifyWriteTxnId types.TxnId, event ReadModifyWriteKeyEvent)

type ReadModifyWriteKeyEvent

type ReadModifyWriteKeyEvent struct {
	Key  string
	Type ReadModifyWriteKeyEventType
}

func (ReadModifyWriteKeyEvent) String

func (e ReadModifyWriteKeyEvent) String() string

type ReadModifyWriteKeyEventType

type ReadModifyWriteKeyEventType int
const (
	ReadModifyWriteKeyEventTypeInvalid ReadModifyWriteKeyEventType = iota
	ReadModifyWriteKeyEventTypeWriteIntentCleared
	ReadModifyWriteKeyEventTypeClearWriteIntentFailed
	ReadModifyWriteKeyEventTypeVersionRemoved
	ReadModifyWriteKeyEventTypeRemoveVersionFailed
	ReadModifyWriteKeyEventTypeKeyWritten
)

func GetReadModifyWriteKeyEventTypeClearWriteIntent

func GetReadModifyWriteKeyEventTypeClearWriteIntent(success bool) ReadModifyWriteKeyEventType

func GetReadModifyWriteKeyEventTypeRemoveVersion

func GetReadModifyWriteKeyEventTypeRemoveVersion(success bool) ReadModifyWriteKeyEventType

func (ReadModifyWriteKeyEventType) String

type Transaction

type Transaction struct {
	sync.RWMutex

	ID types.TxnId
	types.AtomicTxnState

	GC func(*Transaction)
	// contains filtered or unexported fields
}

func (*Transaction) AddUnsafe

func (t *Transaction) AddUnsafe(key string) (addedNewKey bool)

func (*Transaction) ClearWriteIntent

func (t *Transaction) ClearWriteIntent(ctx context.Context, key string, opt types.KVCCUpdateMetaOption) (err error)

func (*Transaction) GetMaxTxnRecordReadVersion

func (t *Transaction) GetMaxTxnRecordReadVersion() uint64

func (*Transaction) GetTxnRecord

func (t *Transaction) GetTxnRecord(ctx context.Context, opt types.KVCCReadOption) (types.ValueCC, error)

func (*Transaction) IsDoneUnsafe

func (t *Transaction) IsDoneUnsafe() bool

func (*Transaction) IsKeyDone

func (t *Transaction) IsKeyDone(key string) (b bool)

func (*Transaction) RemoveTxnRecord

func (t *Transaction) RemoveTxnRecord(ctx context.Context, opt types.KVCCRemoveTxnRecordOption) (err error)

func (*Transaction) RollbackKey

func (t *Transaction) RollbackKey(ctx context.Context, key string, opt types.KVCCRollbackKeyOption) (err error)

func (*Transaction) SetRollbacking

func (t *Transaction) SetRollbacking() (abortOnce bool)

Hide AtomicTxnState::SetRollbacking

func (*Transaction) SetTxnRecord

func (t *Transaction) SetTxnRecord(ctx context.Context, val types.Value, opt types.KVCCWriteOption) error

func (*Transaction) SetTxnState

func (t *Transaction) SetTxnState(_ types.TxnState) (newState types.TxnState, terminateOnce bool)

Hide AtomicTxnState::SetTxnState

func (*Transaction) SetTxnStateUnsafe

func (t *Transaction) SetTxnStateUnsafe(state types.TxnState) (newState types.TxnState)

func (*Transaction) WaitTerminateWithTimeout

func (t *Transaction) WaitTerminateWithTimeout(ctx context.Context, timeout time.Duration) error

type Writer

type Writer struct {
	*Transaction

	Meta       types.DBMeta // NOTE: be cautious not inherit the type, otherwise will cause method conflict problem
	OnUnlocked func()
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(dbMeta types.DBMeta, txn *Transaction) *Writer

func (*Writer) IsWriting

func (w *Writer) IsWriting() bool

func (*Writer) Lock

func (w *Writer) Lock()

func (*Writer) SetResult

func (w *Writer) SetResult(err error)

func (*Writer) Succeeded

func (w *Writer) Succeeded() bool

func (*Writer) ToValue

func (w *Writer) ToValue() types.Value

func (*Writer) Unlock

func (w *Writer) Unlock()

func (*Writer) WaitWritten

func (w *Writer) WaitWritten()

type WritingWriters

type WritingWriters []*Writer

func (WritingWriters) CheckRead

func (writers WritingWriters) CheckRead(ctx context.Context, valVersion uint64, waitTimeout time.Duration) error

Jump to

Keyboard shortcuts

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