proxysql

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 9 Imported by: 0

README

ProxySQL

This package implements freno store support for ProxySQL

Logic

Freno will probe servers found in the stats.stats_mysql_connection_pool ProxySQL admin table that have either status:

  1. ONLINE - connect, ping and replication checks pass
  2. SHUNNED_REPLICATION_LAG - connect and ping checks pass, but replication is lagging

All other statuses are considered unhealthy and therefore are ignored by freno, eg:

  1. SHUNNED - proxysql connot connect and/or ping a backend
  2. OFFLINE_SOFT - a server that is draining, usually for maintenance, etc
  3. OFFLINE_HARD - a server that is completely offline

Requirements

  1. The ProxySQL admin port is reachable to Freno
  2. The ProxySQL global variable admin-stats_credentials is defined
    • ProxySQLUser in MySQLConfigurationSettings (global) or User in ProxySQLConfigurationSettings (per-cluster) must be equal to admin-stats_credentials
    • ProxySQLPassword in MySQLConfigurationSettings (global) or Password in ProxySQLConfigurationSettings (per-cluster) must be equal to admin-stats_credentials
  3. The ProxySQL monitor module is enabled, eg: mysql-monitor_enabled is true
    • The ProxySQL --no-monitor daemon flag cannot be set
  4. The max_replication_lag column is defined for backend servers in the mysql_servers admin table
    • This ensures reads do not receive stale data but lagging nodes are still probed

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the ProxySQL admin client

func NewClient

func NewClient(defaultIgnoreServerTTL time.Duration) *Client

NewClient returns a new ProxySQL admin client

func (*Client) CloseDB

func (c *Client) CloseDB(addr string)

CloseDB closes a ProxySQL admin connection based on an address string

func (*Client) GetDB

func (c *Client) GetDB(settings config.ProxySQLConfigurationSettings) (*sql.DB, string, error)

GetDB returns a configured ProxySQL admin connection

func (*Client) GetServers

func (c *Client) GetServers(db *sql.DB, settings config.ProxySQLConfigurationSettings) (servers []*MySQLConnectionPoolServer, err error)

GetServers returns a list of MySQLConnectionPoolServers with 'ONLINE' or 'SHUNNED_REPLICATION_LAG' status, based on hostgroup ID

type MySQLConnectionPoolServer

type MySQLConnectionPoolServer struct {
	Host   string
	Port   int32
	Status string
}

MySQLConnectionPoolServer represents a row in the stats_mysql_connection_pool table

func (*MySQLConnectionPoolServer) Address

func (ms *MySQLConnectionPoolServer) Address() string

Address returns a string of the hostname/port of a server

Jump to

Keyboard shortcuts

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