Merge branch 'develop' into 1.2.1-binlog_router_trx

This commit is contained in:
MassimilianoPinto
2015-10-23 13:18:11 +02:00
6 changed files with 2393 additions and 2537 deletions

View File

@ -16,22 +16,31 @@ The configuration consists of mandatory and optional parameters.
## Mandatory parameters
### `type`
**`type`** specifies the type of service. For **readwritesplit** module the type is `router`:
type=router
### `router`
**`router`** specifies the router module to be used. For **readwritesplit** the value is `readwritesplit`:
router=readwritesplit
### `servers`
**`servers`** provides a list of servers, which must include one master and available slaves:
servers=server1,server2,server3
**NOTE: Each server on the list must have its own section in the configuration file where it is defined.**
### `user`
**`user`** is the username the router session uses for accessing backends in order to load the content of the `mysql.user` table (and `mysql.db` and database names as well) and optionally for creating, and using `maxscale_schema.replication_heartbeat` table.
### `passwd`
**`passwd`** specifies corresponding password for the user. Syntax for user and passwd is:
```
@ -41,10 +50,13 @@ passwd=<password>
## Optional parameters
### `max_slave_connections`
**`max_slave_connections`** sets the maximum number of slaves a router session uses at any moment. Default value is `1`.
max_slave_connections=<max. number, or % of available slaves>
### `max_slave_replication_lag`
**`max_slave_replication_lag`** specifies how many seconds a slave is allowed to be behind the master. If the lag is bigger than configured value a slave can't be used for routing.
max_slave_replication_lag=<allowed lag in seconds>
@ -52,16 +64,8 @@ passwd=<password>
This applies to Master/Slave replication with MySQL monitor and `detect_replication_lag=1` options set.
Please note max_slave_replication_lag must be greater than monitor interval.
**`router_options`** may include multiple **readwritesplit**-specific options. Values are either singular or parameter-value pairs. Currently available is a single option which specifies the criteria used in slave selection both in initialization of router session and per each query. Note that due to the current monitor implementation, the value specified here should be *<twice the monitor interval>* + 1.
options=slave_selection_criteria=<criteria>
where *<criteria>* is one of the following:
* `LEAST_GLOBAL_CONNECTIONS`, the slave with least connections in total
* `LEAST_ROUTER_CONNECTIONS`, the slave with least connections from this router
* `LEAST_BEHIND_MASTER`, the slave with smallest replication lag
* `LEAST_CURRENT_OPERATIONS` (default), the slave with least active operations
### `use_sql_variables_in`
**`use_sql_variables_in`** specifies where should queries, which read session variable, be routed. The syntax for `use_sql_variable_in` is:
@ -73,6 +77,35 @@ When value all is used, queries reading session variables can be routed to any a
In above-mentioned case the user-defined variable would only be updated in the master where query would be routed due to `INSERT` statement.
## Router options
**`router_options`** may include multiple **readwritesplit**-specific options. All the options are parameter-value pairs. All parameters listed in this section must be configured as a value in `router_options`.
Multiple options can be defined as a comma-separated list of parameter-value pairs.
```
router_options=<option>,<option>
```
### `slave_selection_criteria`
This option controls how the readwritesplit router chooses the slaves it connects to and how the load balancing is done. The default behavior is to route read queries to the slave server with the lowest amount of ongoing queries.
The option syntax:
```
router_options=slave_selection_criteria=<criteria>
```
Where `<criteria>` is one of the following values.
* `LEAST_GLOBAL_CONNECTIONS`, the slave with least connections in total
* `LEAST_ROUTER_CONNECTIONS`, the slave with least connections from this router
* `LEAST_BEHIND_MASTER`, the slave with smallest replication lag
* `LEAST_CURRENT_OPERATIONS` (default), the slave with least active operations
### `max_sescmd_history`
**`max_sescmd_history`** sets a limit on how many session commands each session can execute before the session command history is disabled. The default is an unlimited number of session commands.
```
@ -82,13 +115,17 @@ max_sescmd_history=1500
When a limitation is set, it effectively creates a cap on the session's memory consumption. This might be useful if connection pooling is used and the sessions use large amounts of session commands.
**`disable_sescmd_history`** disables the session command history. This way nothing is stored and if a slave server fails and a new one is taken in its stead, the session on that server will be in an inconsistent state compared to the master server. Disabling session command history will allow connection pooling without causing a constant growth in the memory consumption.
### `disable_sescmd_history`
**`disable_sescmd_history`** disables the session command history. This way no history is stored and if a slave server fails, the router will not try to replace the failed slave. Disabling session command history will allow connection pooling without causing a constant growth in the memory consumption.
```
# Disable the session command history
disable_sescmd_history=true
```
### `master_accept_reads`
**`master_accept_reads`** allows the master server to be used for reads. This is a useful option to enable if you are using a small number of servers and wish to use the master for reads as well.
```
@ -96,9 +133,9 @@ disable_sescmd_history=true
master_accept_reads=true
```
### Routing hints
## Routing hints
The readwritesplit router supports routing hints. For a detailed guide on hint syntax and functionality, please see [this](../Reference/Hint-Syntax.md) document.
The readwritesplit router supports routing hints. For a detailed guide on hint syntax and functionality, please read [this](../Reference/Hint-Syntax.md) document.
## Limitations

File diff suppressed because it is too large Load Diff

View File

@ -25,18 +25,15 @@
#define STRERROR_BUFLEN 512
#endif
typedef struct filewriter_st filewriter_t;
typedef struct logfile_st logfile_t;
typedef struct fnames_conf_st fnames_conf_t;
typedef struct logmanager_st logmanager_t;
typedef enum {
BB_READY = 0x00,
BB_FULL,
BB_CLEARED
typedef enum
{
BB_READY = 0x00,
BB_FULL,
BB_CLEARED
} blockbuf_state_t;
typedef enum {
typedef enum
{
LOGFILE_ERROR = 1,
LOGFILE_FIRST = LOGFILE_ERROR,
LOGFILE_MESSAGE = 2,
@ -46,16 +43,20 @@ typedef enum {
} logfile_id_t;
typedef enum { FILEWRITER_INIT, FILEWRITER_RUN, FILEWRITER_DONE }
filewriter_state_t;
typedef enum
{
FILEWRITER_INIT,
FILEWRITER_RUN,
FILEWRITER_DONE
} filewriter_state_t;
/**
* Thread-specific logging information.
*/
typedef struct log_info_st
typedef struct log_info
{
size_t li_sesid;
int li_enabled_logs;
size_t li_sesid;
int li_enabled_logs;
} log_info_t;
#define LE LOGFILE_ERROR
@ -67,36 +68,36 @@ typedef struct log_info_st
* Check if specified log type is enabled in general or if it is enabled
* for the current session.
*/
#define LOG_IS_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
(log_ses_count[id] > 0 && \
tls_log_info.li_enabled_logs & id)) ? true : false)
#define LOG_IS_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
(log_ses_count[id] > 0 && \
tls_log_info.li_enabled_logs & id)) ? true : false)
#define LOG_MAY_BE_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
log_ses_count[id] > 0) ? true : false)
#define LOG_MAY_BE_ENABLED(id) (((lm_enabled_logfiles_bitmask & id) || \
log_ses_count[id] > 0) ? true : false)
/**
* Execute the given command if specified log is enabled in general or
* if there is at least one session for whom the log is enabled.
*/
#define LOGIF_MAYBE(id,cmd) if (LOG_MAY_BE_ENABLED(id)) \
{ \
cmd; \
}
#define LOGIF_MAYBE(id,cmd) if (LOG_MAY_BE_ENABLED(id)) \
{ \
cmd; \
}
/**
* Execute the given command if specified log is enabled in general or
* if the log is enabled for the current session.
*/
#define LOGIF(id,cmd) if (LOG_IS_ENABLED(id)) \
{ \
cmd; \
}
#define LOGIF(id,cmd) if (LOG_IS_ENABLED(id)) \
{ \
cmd; \
}
#if !defined(LOGIF)
#define LOGIF(id,cmd) if (lm_enabled_logfiles_bitmask & id) \
{ \
cmd; \
}
{ \
cmd; \
}
#endif
/**
@ -106,7 +107,13 @@ typedef struct log_info_st
* RUN Struct is valid for run-time checking.
* DONE means that possible memory allocations have been released.
*/
typedef enum { UNINIT = 0, INIT, RUN, DONE } flat_obj_state_t;
typedef enum
{
UNINIT = 0,
INIT,
RUN,
DONE
} flat_obj_state_t;
/**
* LOG_AUGMENT_WITH_FUNCTION Each logged line is suffixed with [function-name].
@ -144,10 +151,10 @@ void logmanager_enable_syslog(int);
void logmanager_enable_maxscalelog(int);
#define skygw_log_write(id, format, ...)\
skygw_log_write_context(id, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
skygw_log_write_context(id, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
#define skygw_log_write_flush(id, format, ...)\
skygw_log_write_context_flush(id, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
skygw_log_write_context_flush(id, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
/**
* What augmentation if any should a logged message be augmented with.

View File

@ -483,7 +483,7 @@ getDatabases(SERVICE *service, MYSQL *con)
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Loading database names for service %s encountered "
"error: %s.",
"error when querying database privileges: %s.",
service->name,
mysql_error(con))));
return -1;
@ -495,7 +495,7 @@ getDatabases(SERVICE *service, MYSQL *con)
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Loading database names for service %s encountered "
"error: %s.",
"error when storing result set of database privilege query: %s.",
service->name,
mysql_error(con))));
return -1;
@ -527,7 +527,7 @@ getDatabases(SERVICE *service, MYSQL *con)
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Loading database names for service %s encountered "
"error: %s.",
"error when executing SHOW DATABASES query: %s.",
service->name,
mysql_error(con))));
@ -540,7 +540,7 @@ getDatabases(SERVICE *service, MYSQL *con)
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Loading database names for service %s encountered "
"error: %s.",
"error when storing the result set: %s.",
service->name,
mysql_error(con))));

View File

@ -1,329 +1,20 @@
## Example MaxScale.cnf configuration file
#
# MaxScale documentation on GitHub:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Documentation-Contents.md
# Global parameters
#
# Number of worker threads in MaxScale
#
# threads=<number of threads>
#
# Enabled logfiles. The message log is enabled by default and
# the error log is always enabled.
#
# log_messages=<1|0>
# log_trace=<1|0>
# log_debug=<1|0>
## Example:
# Set the number of threads to a value equal to the number of CPU cores.
# Complete list of configuration options:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Getting-Started/Configuration-Guide.md
[maxscale]
threads=4
## Define a monitor that can be used to determine the state and role of
# the servers.
# Server definitions
#
# Currently valid options for all monitors are:
# Set the address of the server to the network
# address of a MySQL server.
#
# module=[mysqlmon|galeramon]
#
# List of server names which are being monitored
#
# servers=<server name 1>,<server name 2>,...,<server name N>
#
# Username for monitor queries, need slave replication and slave client privileges
# Password in plain text format, and monitor's sampling interval in milliseconds.
#
# user=<username>
# passwd=<plain txt password>
# monitor_interval=<sampling interval in milliseconds> (default 10000)
#
# Timeouts for monitor operations in backend servers - optional.
#
# backend_connect_timeout=<timeout in seconds>
# backend_write_timeout=<timeout in seconds>
# backend_read_timeout=<timeout in seconds>
#
## MySQL monitor-specific options:
#
# Enable detection of replication slaves lag via replication_heartbeat
# table - optional.
#
# detect_replication_lag=[1|0] (default 0)
#
# Allow previous master to be available even in case of stopped or misconfigured
# replication - optional.
#
# detect_stale_master=[1|0] (default 0)
#
## Galera monitor-specific options:
#
# If disable_master_failback is not set, recovery of previously failed master
# causes mastership to be switched back to it. Enabling the option prevents it.
#
# disable_master_failback=[0|1] (default 0)
#
## Examples:
[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1,server2,server3
user=myuser
passwd=mypwd
monitor_interval=10000
#backend_connect_timeout=
#backend_read_timeout=
#backend_write_timeout=
#detect_replication_lag=
#detect_stale_master=
[Galera Monitor]
type=monitor
module=galeramon
servers=server1,server2,server3
user=myuser
passwd=mypwd
monitor_interval=10000
#disable_master_failback=
## Filter definition
#
# Type specifies the section
#
# type=filter
#
# Module specifies which module implements the filter function
#
# module=[qlafilter|regexfilter|topfilter|teefilter]
#
# Options specify the log file for Query Log Filter
#
# options=<path to logfile>
#
# Match and replace are used in regexfilter
#
# match=fetch
# replace=select
#
# Count and filebase are used with topfilter to specify how many top queries are
# listed and where.
#
# count=<count>
# filebase=<path to output file>
#
# Match and service are used by tee filter to specify what queries should be
# duplicated and where the copy should be routed.
#
# match=insert.*HighScore.*values
# service=Cassandra
#
## Examples:
[qla]
type=filter
module=qlafilter
options=/tmp/QueryLog
[fetch]
type=filter
module=regexfilter
match=fetch
replace=select
[hint]
type=filter
module=hintfilter
## A series of service definition
#
# Name of router module, currently valid options are
#
# router=[readconnroute|readwritesplit|debugcli|CLI]
#
# List of server names for use of service - mandatory for readconnroute,
# readwritesplit, and debugcli
#
# servers=<server name 1>,<server name 2>,...,<server name N>
#
# Username to fetch password information with and password in plaintext
# format - for readconnroute and readwritesplit
#
# user=<username>
# passwd=<password in plain text format>
#
# flag for enabling the use of root user - for readconnroute and
# readwritesplite - optional.
#
# enable_root_user=[0|1] (default 0)
#
# Version string to be used in server handshake. Default value is that of
# MariaDB embedded library's - for readconnroute and readwritesplite - optional.
#
# version_string=<specific version string>
#
# Filters specify the filters through which the query is transferred and the
# order of their appearance on the list corresponds the order they are
# used. Values refer to names of filters configured in this file - for
# readconnroute and readwritesplit - optional.
#
# filters=<filter name1|filter name2|...|filter nameN>
#
## Read Connection Router specific router options.
#
# router_options specify the role in which the selected server must be.
#
# router_options=[master|slave|synced]
#
## Read/Write Split Router specific options.
#
# use_sql_variables_in specifies where sql variable modifications are
# routed - optional.
#
# use_sql_variables_in=[master|all] (default all)
#
# router_options=slave_selection_criteria specifies the selection criteria for
# slaves both in new session creation and when route target is selected - optional.
#
# router_options=
# slave_selection_criteria=[LEAST_CURRENT_OPERATIONS|LEAST_BEHIND_MASTER]
#
# router_options=max_sescmd_history specifies a limit on the number of 'session commands'
# a single session can execute. Please refer to the configuration guide for more details - optional.
#
# router_options=
# max_sescmd_history=2500
#
# max_slave_connections specifies how many slaves a router session can
# connect to - optional.
#
# max_slave_connections=<number, or percentage, of all slaves>
#
# max_slave_replication_lag specifies how much a slave is allowed to be behind
# the master and still become chosen routing target - optional, requires that
# monitor has detect_replication_lag=1 .
#
# max_slave_replication_lag=<allowed lag in seconds for a slave>
#
# Valid router modules currently are:
# readwritesplit, readconnroute, debugcli and CLI
#
## Examples:
[Read Connection Router]
type=service
router=readconnroute
servers=server1,server2,server3
user=myuser
passwd=mypwd
router_options=slave
[RW Split Router]
type=service
router=readwritesplit
servers=server1,server2,server3
user=myuser
passwd=mypwd
max_slave_connections=100%
#use_sql_variables_in=master
#max_slave_replication_lag=21
#filters=hint|fetch|qla
#router_options=slave_selection_criteria=LEAST_CURRENT_OPERATIONS
# Uncomment this to disable the saving of session modifying comments. Some scripting
# languages use connection pooling and will use the same session. MaxScale sees them
# as the same session and stores them for the slave recovery process.
#router_options=disable_sescmd_history=true,disable_slave_recovery=true
# This will allow the master server to be used for read queries. By default
# MaxScale will only use the master for write queries.
#router_options=master_accept_reads=true
[Debug Interface]
type=service
router=debugcli
[CLI]
type=service
router=cli
## Listener definitions for the services
#
# Type specifies section as listener one
#
# type=listener
#
# Service links the section to one of the service names used in this configuration
#
# service=<name of service section>
#
# Protocol is client protocol library name.
#
# protocol=[MySQLClient|telnetd|HTTPD|maxscaled]
#
# Port and address specify which port the service listens and the address limits
# listening to a specific network interface only. Address is optional.
#
# port=<Listening port>
# address=<Address to bind to>
#
# Socket is alternative for address. The specified socket path must be writable
# by the Unix user MaxScale runs as.
#
# socket=<Listening socket>
#
## Examples:
[Read Connection Listener]
type=listener
service=Read Connection Router
protocol=MySQLClient
address=192.168.100.102
port=4008
socket=/var/lib/maxscale/readconn.sock
[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
#socket=/var/lib/maxscale/rwsplit.sock
[Debug Listener]
type=listener
service=Debug Interface
protocol=telnetd
address=127.0.0.1
port=4442
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
port=6603
## Definition of the servers
#
# Type specifies the section as server one
#
# type=server
#
# The IP address or hostname of the machine running the database server that is
# being defined. MaxScale will use this address to connect to the backend
# database server.
#
# address=<IP|hostname>
#
# The port on which the database listens for incoming connections. MaxScale
# will use this port to connect to the database server.
#
# port=<port>
#
# The name for the protocol module to use to connect MaxScale to the database.
# Currently the only backend protocol supported is the MySQLBackend module.
#
# protocol=MySQLBackend
#
## Examples:
[server1]
type=server
@ -331,14 +22,76 @@ address=127.0.0.1
port=3306
protocol=MySQLBackend
[server2]
type=server
address=127.0.0.1
port=3306
protocol=MySQLBackend
# Monitor for the servers
#
# This will keep MaxScale aware of the state of the servers.
# MySQL Monitor documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Monitors/MySQL-Monitor.md
[server3]
type=server
address=127.0.0.1
port=3306
protocol=MySQLBackend
[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1
user=myuser
passwd=mypwd
monitor_interval=10000
# Service definitions
#
# Service Definition for a read-only service and
# a read/write splitting service.
#
# ReadConnRoute documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Routers/ReadConnRoute.md
[Read-Only Service]
type=service
router=readconnroute
servers=server1
user=myuser
passwd=mypwd
router_options=slave
# ReadWriteSplit documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Routers/ReadWriteSplit.md
[Read-Write Service]
type=service
router=readwritesplit
servers=server1
user=myuser
passwd=mypwd
max_slave_connections=100%
# This service enables the use of the MaxAdmin interface
# MaxScale administration guide:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Reference/MaxAdmin.md
[MaxAdmin Service]
type=service
router=cli
# Listener definitions for the services
#
# These listeners represent the ports the
# services will listen on.
#
[Read-Only Listener]
type=listener
service=Read-Only Service
protocol=MySQLClient
port=4008
[Read-Write Listener]
type=listener
service=Read-Write Service
protocol=MySQLClient
port=4006
[MaxAdmin Listener]
type=listener
service=MaxAdmin Service
protocol=maxscaled
port=6603

View File

@ -297,11 +297,16 @@ char task_name[BLRM_TASK_NAME_LEN+1] = "";
{
my_uuid(defuuid);
if ((inst->uuid = (char *)malloc(38)) != NULL)
sprintf(inst->uuid, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
defuuid[0], defuuid[1], defuuid[2], defuuid[3],
defuuid[4], defuuid[5], defuuid[6], defuuid[7],
defuuid[8], defuuid[9], defuuid[10], defuuid[11],
defuuid[12], defuuid[13], defuuid[14], defuuid[15]);
sprintf(inst->uuid,
"%02hhx%02hhx%02hhx%02hhx-"
"%02hhx%02hhx-"
"%02hhx%02hhx-"
"%02hhx%02hhx-"
"%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",
defuuid[0], defuuid[1], defuuid[2], defuuid[3],
defuuid[4], defuuid[5], defuuid[6], defuuid[7],
defuuid[8], defuuid[9], defuuid[10], defuuid[11],
defuuid[12], defuuid[13], defuuid[14], defuuid[15]);
}
/*