storage

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWriteConflict write conflict
	ErrWriteConflict = moerr.NewError(moerr.ErrTxnWriteConflict, "write conflict")
	// ErrUnreslovedConflict read unresoved conflict
	ErrUnreslovedConflict = moerr.NewError(moerr.ErrMissingTxn, "unresloved conflict")
	// ErrMissingTxn missing txn
	ErrMissingTxn = moerr.NewError(moerr.ErrMissingTxn, "missing txn")
)

Functions

This section is empty.

Types

type ReadResult

type ReadResult interface {
	// WaitTxns returns the ID of the concurrent write transaction encountered.
	WaitTxns() [][]byte
	// Read perform a read operation really. There is a TxnService to ensure that the transaction to be waited for
	// has finished(Committed or Aborted).
	Read() ([]byte, error)
	// Release release the ReadResult. TxnStorage can resuse the response data and the ReadResult.
	Release()
}

ReadResult read result from TxnStorage. When a read operation encounters any concurrent write transaction, it is necessary to wait for the write transaction to complete to confirm that the latest write is visible to the current transaction.

To avoid the read Payload being parsed multiple times, TxnStorage can store the parsed state in the ReadResult and continue to use it while the ReadResult continues.

type TxnStorage

type TxnStorage interface {
	// StartRecovery start txnStorage recovery process. Use the incoming channel to send the Txn that needs to be
	// recovered and close the channel when all the logs have been processed.
	StartRecovery(chan txn.TxnMeta)

	// Read execute read requests sent by CN.
	//
	// The Payload parameter is unsafe and should no longer be held by Storage
	// after the return of the current call.
	//
	// If any of the data in the current read has been written by other transactions,
	// these write transaction IDs need to be returned. The transaction IDs that need to be returned include
	// the following:
	// case1. Txn.Status == Committing && CurrentTxn.SnapshotTimestamp > Txn.CommitTimestamp
	// case2. Txn.Status == Prepared && CurrentTxn.SnapshotTimestamp > Txn.PreparedTimestamp
	Read(txnMeta txn.TxnMeta, op uint32, payload []byte) (ReadResult, error)
	// Write execute write requests sent by CN.
	// TODO: Handle spec error by storage.
	Write(txnMeta txn.TxnMeta, op uint32, payload []byte) ([]byte, error)
	// Prepare prepare data written by a transaction on a DNShard. TxnStorage needs to do conflict
	// detection locally. The txn metadata(status change to prepared) and the data should be written to
	// LogService.
	//
	// Note that for a distributed transaction, when all DNShards are Prepared, then the transaction is
	// considered to have been committed.
	Prepare(txnMeta txn.TxnMeta) error
	// Committing for distributed transactions, all participating DNShards have been PREPARED and the status
	// of the transaction is logged to the LogService.
	Committing(txnMeta txn.TxnMeta) error
	// Commit commit the transaction. TxnStorage needs to do conflict locally.
	Commit(txnMeta txn.TxnMeta) error
	// Rollback rollback the transaction.
	Rollback(txnMeta txn.TxnMeta) error
}

TxnStorage In order for TxnService to implement distributed transactions based on Clock-SI on a stand-alone storage engine, it requires a number of interfaces implemented by the storage engine.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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