buffer

package
v3.0.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

func New() *Buffer

New creates a new Buffer object.

func (*Buffer) Shutdown

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

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

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

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.

Jump to

Keyboard shortcuts

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