Replication and Variables
System variables are not replicated correctly when using STATEMENT
mode, except for the following variables when they are used with session scope:
auto_increment_increment
auto_increment_offset
character_set_client
character_set_connection
character_set_database
character_set_server
collation_connection
collation_database
collation_server
foreign_key_checks
identity
last_insert_id
lc_time_names
pseudo_thread_id
sql_auto_is_null
time_zone
timestamp
unique_checks
When MIXED
mode is used, the variables in the preceding list, when used with session scope, cause a switch from statement-based to row-based logging. See , "Mixed Binary Logging Format".
sql-mode
is also replicated except for the NO_DIR_IN_CREATE
mode; the slave always preserves its own value for NO_DIR_IN_CREATE
, regardless of changes to it on the master. This is true for all replication formats.
However, when mysqlbinlog parses a SET @@sql_mode =
statement, the full mode
mode
value, including NO_DIR_IN_CREATE
, is passed to the receiving server. For this reason, replication of such a statement may not be safe when STATEMENT
mode is in use.
The default-storage-engine
and storage_engine
system variables are not replicated, regardless of the logging mode; this is intended to facilitate replication between different storage engines.
The read_only
system variable is not replicated. In addition, the enabling this variable has different effects with regard to temporary tables, table locking, and the SET PASSWORD
statement in different MariaDB versions.
The max_heap_table_size
system variable is not replicated. Increasing the value of this variable on the master without doing so on the slave can lead eventually to Table is full errors on the slave when trying to execute INSERT
statements on a MEMORY
table on the master that is thus permitted to grow larger than its counterpart on the slave. For more information, see , "Replication and MEMORY
Tables".
In statement-based replication, session variables are not replicated properly when used in statements that update tables. For example, the following sequence of statements will not insert the same data on the master and the slave:
SET max_join_size=1000; INSERT INTO mytable VALUES(@@max_join_size);
This does not apply to the common sequence:
SET time_zone=...; INSERT INTO mytable VALUES(CONVERT_TZ(..., ..., @@time_zone));
Replication of session variables is not a problem when row-based replication is being used, in which case, session variables are always replicated safely. See , "Replication Formats".
In MariaDB 5.6, the following session variables are written to the binary log and honored by the replication slave when parsing the binary log, regardless of the logging format:
sql_mode
foreign_key_checks
unique_checks
character_set_client
collation_connection
collation_database
collation_server
sql_auto_is_null
Even though session variables relating to character sets and collations are written to the binary log, replication between different character sets is not supported.
To help reduce possible confusion, we recommend that you always use the same setting for the lower_case_table_names
system variable on both master and slave, especially when you are running MariaDB on platforms with case-sensitive file systems.Note
In previous versions of MySQL, when a case-sensitive file system was in use, setting this variable to 1 on the slave and to a different value on the master could lead to replication failure. This issue is fixed in MariaDB 5.6.1. (Bug #37656)