go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/vttablet/tabletserver/txserializer Index | Files

package txserializer

import "gopkg.in/src-d/go-vitess.v1/vt/vttablet/tabletserver/txserializer"

Package txserializer provides the vttablet hot row protection. See the TxSerializer struct for details.

Index

Package Files

tx_serializer.go

type DoneFunc Uses

type DoneFunc func()

DoneFunc is returned by Wait() and must be called by the caller.

type TxSerializer Uses

type TxSerializer struct {
    *sync2.ConsolidatorCache
    // contains filtered or unexported fields
}

TxSerializer serializes incoming transactions which target the same row range i.e. table name and WHERE clause are identical. Additional transactions are queued and woken up in arrival order.

This implementation has some parallels to the sync2.Consolidator class. However, there are many substantial differences: - Results are not shared between queued transactions. - Only one waiting transaction and not all are notified when the current one

has finished.

- Waiting transactions are woken up in FIFO order. - Waiting transactions are unblocked if their context is done. - Both the local queue (per row range) and global queue (whole process) are

limited to avoid that queued transactions can consume the full capacity
of vttablet. This is important if the capaciy is finite. For example, the
number of RPCs in flight could be limited by the RPC subsystem.

func New Uses

func New(dryRun bool, maxQueueSize, maxGlobalQueueSize, concurrentTransactions int) *TxSerializer

New returns a TxSerializer object.

func (*TxSerializer) Pending Uses

func (t *TxSerializer) Pending(key string) int

Pending returns the number of queued transactions (including the ones which are currently in flight.)

func (*TxSerializer) ServeHTTP Uses

func (t *TxSerializer) ServeHTTP(response http.ResponseWriter, request *http.Request)

ServeHTTP lists the most recent, cached queries and their count.

func (*TxSerializer) Wait Uses

func (t *TxSerializer) Wait(ctx context.Context, key, table string) (done DoneFunc, waited bool, err error)

Wait blocks if another transaction for the same range is already in flight. It returns when this transaction has its turn. "done" is != nil if err == nil and must be called once the transaction is done and the next waiting transaction can be unblocked. "waited" is true if Wait() had to wait for other transactions. "err" is not nil if a) the context is done or b) a queue limit was reached.

Package txserializer imports 12 packages (graph) and is imported by 1 packages. Updated 2019-07-09. Refresh now. Tools for package owners.