go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/vtgate/buffer Index | Files

package buffer

import "gopkg.in/src-d/go-vitess.v1/vt/vtgate/buffer"

Package buffer provides a buffer for MASTER traffic during failovers.

Instead of returning an error to the application (when the vttablet master becomes unavailable), the buffer will automatically retry buffered requests after the end of the failover was detected.

Buffering (stalling) requests will increase the number of requests in flight within vtgate and at upstream layers. Therefore, it is important to limit the size of the buffer and the buffering duration (window) per request. See the file flags.go for the available configuration and its defaults.

Index

Package Files

buffer.go flags.go shard_buffer.go timeout_thread.go variables.go

type Buffer Uses

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

Buffer is used to track ongoing MASTER tablet failovers and buffer requests while the MASTER tablet is unavailable. Once the new MASTER starts accepting requests, buffering stops and requests queued so far will be automatically retried.

There should be exactly one instance of this buffer. For each failover, an instance of "ShardBuffer" will be created.

func New Uses

func New() *Buffer

New creates a new Buffer object.

func (*Buffer) Shutdown Uses

func (b *Buffer) Shutdown()

Shutdown blocks until all pending ShardBuffer objects are shut down. In particular, it guarantees that all launched Go routines are stopped after it returns.

func (*Buffer) StatsUpdate Uses

func (b *Buffer) StatsUpdate(ts *discovery.TabletStats)

StatsUpdate keeps track of the "tablet_externally_reparented_timestamp" of each master. This way we can detect the end of a failover. It is part of the discovery.HealthCheckStatsListener interface.

func (*Buffer) WaitForFailoverEnd Uses

func (b *Buffer) WaitForFailoverEnd(ctx context.Context, keyspace, shard string, err error) (RetryDoneFunc, error)

WaitForFailoverEnd blocks until a pending buffering due to a failover for keyspace/shard is over. If there is no ongoing failover, "err" is checked. If it's caused by a failover, buffering may be started. It returns an error if buffering failed (e.g. buffer full). If it does not return an error, it may return a RetryDoneFunc which must be called after the request was retried.

type RetryDoneFunc Uses

type RetryDoneFunc context.CancelFunc

RetryDoneFunc will be returned for each buffered request and must be called after the buffered request was retried. Without this signal, the buffer would not know how many buffered requests are currently retried.

Package buffer imports 17 packages (graph) and is imported by 2 packages. Updated 2019-06-13. Refresh now. Tools for package owners.