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 ¶
func CausedByFailover ¶ added in v0.11.0
CausedByFailover returns true if "err" was supposedly caused by a failover. To simplify things, we've merged the detection for different MySQL flavors in one function. Supported flavors: MariaDB, MySQL, Google internal.
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 (*Buffer) ProcessMasterHealth ¶
func (b *Buffer) ProcessMasterHealth(th *discovery.TabletHealth)
ProcessMasterHealth notifies the buffer to record a new master and end any failover buffering that may be in progress
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.LegacyTabletStats)
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.LegacyHealthCheckStatsListener 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.