summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2017-11-07 11:04:45 +0200
committerMonty <monty@mariadb.org>2017-12-03 13:58:35 +0200
commitb016e1ba7f649256c53e9cad3b0c61b76c02fcf1 (patch)
tree97cdd17b6e3f4cc2225f2578330969641ea1eedd
parent3907ff2d24137dd428e153f6f2b57dd13272a55f (diff)
downloadmariadb-git-b016e1ba7f649256c53e9cad3b0c61b76c02fcf1.tar.gz
MDEV-7702 Spiral patch 004_mariadb-10.0.15.slave-trx-retry.diff
This is about adding more options to force slave retries Two new variables has been added: slave_transaction_retry_errors - Tells the slave thread to retry transaction for replication when a query event returns an error from the provided list. Deadlock and elapsed lock wait timeout errors are automatically added to this list slave-transaction-retry-interval - Interval of the slave SQL thread will retry a transaction in case it failed with a deadlock or elapsed lock wait timeout or listed in slave_transaction_retry_errors Other changes: - Simplifed code for slave_skip_errors (to be aligned with slave_transaction_retry_errors) - Renamed print_slave_skip_errors() to make_slave_skip_errors_printable() - Remove printing error from init_slave_skip_errors as my_bitmap_init() will do that if needed. - Generalize has_temporary_error()
-rw-r--r--mysql-test/r/mysqld--help.result19
-rw-r--r--mysql-test/suite/sys_vars/r/slave_transaction_retry_errors.result21
-rw-r--r--mysql-test/suite/sys_vars/r/slave_transaction_retry_interval_basic.result126
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff43
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result30
-rw-r--r--mysql-test/suite/sys_vars/t/slave_transaction_retry_errors-master.opt1
-rw-r--r--mysql-test/suite/sys_vars/t/slave_transaction_retry_errors.test19
-rw-r--r--mysql-test/suite/sys_vars/t/slave_transaction_retry_interval_basic.test190
-rw-r--r--sql/mysqld.cc8
-rw-r--r--sql/mysqld.h1
-rw-r--r--sql/slave.cc173
-rw-r--r--sql/slave.h7
-rw-r--r--sql/sys_vars.cc21
13 files changed, 595 insertions, 64 deletions
diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result
index dfd64e2c1fe..0992276227f 100644
--- a/mysql-test/r/mysqld--help.result
+++ b/mysql-test/r/mysqld--help.result
@@ -1118,8 +1118,19 @@ The following options may be given as the first argument:
(Defaults to on; use --skip-slave-sql-verify-checksum to disable.)
--slave-transaction-retries=#
Number of times the slave SQL thread will retry a
- transaction in case it failed with a deadlock or elapsed
- lock wait timeout, before giving up and stopping
+ transaction in case it failed with a deadlock, elapsed
+ lock wait timeout or listed in
+ slave_transaction_retry_errors, before giving up and
+ stopping
+ --slave-transaction-retry-errors=name
+ Tells the slave thread to retry transaction for
+ replication when a query event returns an error from the
+ provided list. Deadlock and elapsed lock wait timeout
+ errors are automatically added to this list
+ --slave-transaction-retry-interval=#
+ Interval of the slave SQL thread will retry a transaction
+ in case it failed with a deadlock or elapsed lock wait
+ timeout or listed in slave_transaction_retry_errors
--slave-type-conversions=name
Set of slave type conversions that are enabled. If the
variable is empty, no conversions are allowed and it is
@@ -1585,9 +1596,11 @@ slave-parallel-mode conservative
slave-parallel-threads 0
slave-parallel-workers 0
slave-run-triggers-for-rbr NO
-slave-skip-errors (No default value)
+slave-skip-errors OFF
slave-sql-verify-checksum TRUE
slave-transaction-retries 10
+slave-transaction-retry-errors 1213,1205
+slave-transaction-retry-interval 0
slave-type-conversions
slow-launch-time 2
slow-query-log FALSE
diff --git a/mysql-test/suite/sys_vars/r/slave_transaction_retry_errors.result b/mysql-test/suite/sys_vars/r/slave_transaction_retry_errors.result
new file mode 100644
index 00000000000..a7815bb3f78
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_transaction_retry_errors.result
@@ -0,0 +1,21 @@
+select @@global.slave_transaction_retry_errors;
+@@global.slave_transaction_retry_errors
+1213,1205,10,20,400
+select @@session.slave_transaction_retry_errors;
+ERROR HY000: Variable 'slave_transaction_retry_errors' is a GLOBAL variable
+show global variables like 'slave_transaction_retry_errors';
+Variable_name Value
+slave_transaction_retry_errors 1213,1205,10,20,400
+show session variables like 'slave_transaction_retry_errors';
+Variable_name Value
+slave_transaction_retry_errors 1213,1205,10,20,400
+select * from information_schema.global_variables where variable_name='slave_transaction_retry_errors';
+VARIABLE_NAME VARIABLE_VALUE
+SLAVE_TRANSACTION_RETRY_ERRORS 1213,1205,10,20,400
+select * from information_schema.session_variables where variable_name='slave_transaction_retry_errors';
+VARIABLE_NAME VARIABLE_VALUE
+SLAVE_TRANSACTION_RETRY_ERRORS 1213,1205,10,20,400
+set global slave_transaction_retry_errors=1;
+ERROR HY000: Variable 'slave_transaction_retry_errors' is a read only variable
+set session slave_transaction_retry_errors=1;
+ERROR HY000: Variable 'slave_transaction_retry_errors' is a read only variable
diff --git a/mysql-test/suite/sys_vars/r/slave_transaction_retry_interval_basic.result b/mysql-test/suite/sys_vars/r/slave_transaction_retry_interval_basic.result
new file mode 100644
index 00000000000..8be45f83341
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_transaction_retry_interval_basic.result
@@ -0,0 +1,126 @@
+SET @start_global_value = @@global.slave_transaction_retry_interval;
+SELECT @start_global_value;
+@start_global_value
+0
+'#--------------------FN_DYNVARS_149_01-------------------------#'
+SET @@global.slave_transaction_retry_interval = 50;
+SET @@global.slave_transaction_retry_interval = DEFAULT;
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+0
+'#--------------------FN_DYNVARS_149_02-------------------------#'
+SET @@global.slave_transaction_retry_interval = DEFAULT;
+SELECT @@global.slave_transaction_retry_interval = 10;
+@@global.slave_transaction_retry_interval = 10
+0
+'#--------------------FN_DYNVARS_149_03-------------------------#'
+SET @@global.slave_transaction_retry_interval = 0;
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+0
+SET @@global.slave_transaction_retry_interval = 1;
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+1
+SET @@global.slave_transaction_retry_interval = 15;
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+15
+SET @@global.slave_transaction_retry_interval = 1024;
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+1024
+SET @@global.slave_transaction_retry_interval = 2147483648;
+Warnings:
+Warning 1292 Truncated incorrect slave_transaction_retry_interval value: '2147483648'
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+3600
+SET @@global.slave_transaction_retry_interval = 2147483648*2-1;
+Warnings:
+Warning 1292 Truncated incorrect slave_transaction_retry_interval value: '4294967295'
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+3600
+SET @@global.slave_transaction_retry_interval = 2147483649*2;
+Warnings:
+Warning 1292 Truncated incorrect slave_transaction_retry_interval value: '4294967298'
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+3600
+SET @@global.slave_transaction_retry_interval = 4294967295;
+Warnings:
+Warning 1292 Truncated incorrect slave_transaction_retry_interval value: '4294967295'
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+3600
+'#--------------------FN_DYNVARS_149_04-------------------------#'
+SET @@slave_transaction_retry_interval = 2;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+SET @@session.slave_transaction_retry_interval = 3;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+SET @@local.slave_transaction_retry_interval = 4;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+'#------------------FN_DYNVARS_149_05-----------------------#'
+SET @@global.slave_transaction_retry_interval = -1;
+Warnings:
+Warning 1292 Truncated incorrect slave_transaction_retry_interval value: '-1'
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+0
+SET @@global.slave_transaction_retry_interval = 2147483649*2147483649;
+Warnings:
+Warning 1292 Truncated incorrect slave_transaction_retry_interval value: '4611686022722355201'
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+3600
+SET @@global.slave_transaction_retry_interval = 65530.34;
+ERROR 42000: Incorrect argument type to variable 'slave_transaction_retry_interval'
+SET @@global.slave_transaction_retry_interval = '100';
+ERROR 42000: Incorrect argument type to variable 'slave_transaction_retry_interval'
+SET @@global.slave_transaction_retry_interval = 7483649.56;
+ERROR 42000: Incorrect argument type to variable 'slave_transaction_retry_interval'
+SET @@global.slave_transaction_retry_interval = ON;
+ERROR 42000: Incorrect argument type to variable 'slave_transaction_retry_interval'
+SET @@global.slave_transaction_retry_interval = OFF;
+ERROR 42000: Incorrect argument type to variable 'slave_transaction_retry_interval'
+'#------------------FN_DYNVARS_149_06-----------------------#'
+SET @@global.slave_transaction_retry_interval = 3000;
+SELECT @@global.slave_transaction_retry_interval = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='slave_transaction_retry_interval';
+@@global.slave_transaction_retry_interval = VARIABLE_VALUE
+1
+'#------------------FN_DYNVARS_149_07-----------------------#'
+SELECT count(VARIABLE_VALUE)
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='slave_transaction_retry_interval';
+count(VARIABLE_VALUE)
+1
+'#------------------FN_DYNVARS_149_08-----------------------#'
+SET @@global.slave_transaction_retry_interval = TRUE;
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+1
+SET @@global.slave_transaction_retry_interval = FALSE;
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+0
+'#---------------------FN_DYNVARS_149_09----------------------#'
+SET @@global.slave_transaction_retry_interval = 60*60;
+SELECT @@slave_transaction_retry_interval = @@global.slave_transaction_retry_interval;
+@@slave_transaction_retry_interval = @@global.slave_transaction_retry_interval
+1
+'#---------------------FN_DYNVARS_149_10----------------------#'
+SET slave_transaction_retry_interval = 2048;
+ERROR HY000: Variable 'slave_transaction_retry_interval' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT slave_transaction_retry_interval;
+ERROR 42S22: Unknown column 'slave_transaction_retry_interval' in 'field list'
+SELECT @@slave_transaction_retry_interval;
+@@slave_transaction_retry_interval
+3600
+SET global slave_transaction_retry_interval = 99;
+SET @@global.slave_transaction_retry_interval = @start_global_value;
+SELECT @@global.slave_transaction_retry_interval;
+@@global.slave_transaction_retry_interval
+0
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
index b27c493c6c4..8b0749810e9 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
@@ -1176,11 +1176,20 @@
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
- VARIABLE_COMMENT Number of times the slave SQL thread will retry a transaction in case it failed with a deadlock or elapsed lock wait timeout, before giving up and stopping
+ VARIABLE_COMMENT Number of times the slave SQL thread will retry a transaction in case it failed with a deadlock, elapsed lock wait timeout or listed in slave_transaction_retry_errors, before giving up and stopping
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -4426,7 +4426,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
+ DEFAULT_VALUE 0
+ VARIABLE_SCOPE GLOBAL
+-VARIABLE_TYPE BIGINT UNSIGNED
++VARIABLE_TYPE INT UNSIGNED
+ VARIABLE_COMMENT Interval of the slave SQL thread will retry a transaction in case it failed with a deadlock or elapsed lock wait timeout or listed in slave_transaction_retry_errors
+ NUMERIC_MIN_VALUE 0
+ NUMERIC_MAX_VALUE 3600
+@@ -4257,7 +4257,7 @@
+ GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 2
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
@@ -1188,7 +1197,7 @@
VARIABLE_COMMENT If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 31536000
-@@ -4485,7 +4485,7 @@
+@@ -4316,7 +4316,7 @@
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Each thread that needs to do a sort allocates a buffer of this size
NUMERIC_MIN_VALUE 1024
@@ -1197,7 +1206,7 @@
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
-@@ -4790,7 +4790,7 @@
+@@ -4621,7 +4621,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 256
VARIABLE_SCOPE GLOBAL
@@ -1206,7 +1215,7 @@
VARIABLE_COMMENT The soft upper limit for number of cached stored routines for one connection.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 524288
-@@ -4888,7 +4888,7 @@
+@@ -4719,7 +4719,7 @@
GLOBAL_VALUE_ORIGIN AUTO
DEFAULT_VALUE 400
VARIABLE_SCOPE GLOBAL
@@ -1215,7 +1224,7 @@
VARIABLE_COMMENT The number of cached table definitions
NUMERIC_MIN_VALUE 400
NUMERIC_MAX_VALUE 524288
-@@ -4902,7 +4902,7 @@
+@@ -4733,7 +4733,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 2000
VARIABLE_SCOPE GLOBAL
@@ -1224,7 +1233,7 @@
VARIABLE_COMMENT The number of cached open tables
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 1048576
-@@ -4972,7 +4972,7 @@
+@@ -4761,7 +4761,7 @@
GLOBAL_VALUE_ORIGIN AUTO
DEFAULT_VALUE 256
VARIABLE_SCOPE GLOBAL
@@ -1233,7 +1242,7 @@
VARIABLE_COMMENT How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 16384
-@@ -4986,7 +4986,7 @@
+@@ -4775,7 +4775,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 10
VARIABLE_SCOPE GLOBAL
@@ -1242,7 +1251,7 @@
VARIABLE_COMMENT Permits the application to give the threads system a hint for the desired number of threads that should be run at the same time.This variable has no effect, and is deprecated. It will be removed in a future release.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 512
-@@ -5191,15 +5191,15 @@
+@@ -4980,15 +4980,15 @@
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME TMP_DISK_TABLE_SIZE
@@ -1262,7 +1271,7 @@
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
-@@ -5213,7 +5213,7 @@
+@@ -5002,7 +5002,7 @@
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table. Same as tmp_table_size.
NUMERIC_MIN_VALUE 1024
@@ -1271,7 +1280,7 @@
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
-@@ -5227,7 +5227,7 @@
+@@ -5016,7 +5016,7 @@
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Alias for tmp_memory_table_size. If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table.
NUMERIC_MIN_VALUE 1024
@@ -1280,7 +1289,7 @@
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
-@@ -5238,7 +5238,7 @@
+@@ -5027,7 +5027,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 8192
VARIABLE_SCOPE SESSION
@@ -1289,7 +1298,7 @@
VARIABLE_COMMENT Allocation block size for transactions to be stored in binary log
NUMERIC_MIN_VALUE 1024
NUMERIC_MAX_VALUE 134217728
-@@ -5252,7 +5252,7 @@
+@@ -5041,7 +5041,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 4096
VARIABLE_SCOPE SESSION
@@ -1298,7 +1307,7 @@
VARIABLE_COMMENT Persistent buffer for transactions to be stored in binary log
NUMERIC_MIN_VALUE 1024
NUMERIC_MAX_VALUE 134217728
-@@ -5350,7 +5350,7 @@
+@@ -5139,7 +5139,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 28800
VARIABLE_SCOPE SESSION
@@ -1307,7 +1316,7 @@
VARIABLE_COMMENT The number of seconds the server waits for activity on a connection before closing it
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 31536000
-@@ -5455,7 +5455,7 @@
+@@ -5243,7 +5243,7 @@
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME OPEN_FILES_LIMIT
VARIABLE_SCOPE GLOBAL
@@ -1316,7 +1325,7 @@
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
-@@ -5468,7 +5468,7 @@
+@@ -5256,7 +5256,7 @@
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes
NUMERIC_MIN_VALUE 0
@@ -1325,7 +1334,7 @@
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
-@@ -5478,7 +5478,7 @@
+@@ -5266,7 +5266,7 @@
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes
NUMERIC_MIN_VALUE 0
@@ -1334,7 +1343,7 @@
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
-@@ -5573,7 +5573,7 @@
+@@ -5351,7 +5351,7 @@
VARIABLE_NAME LOG_TC_SIZE
GLOBAL_VALUE_ORIGIN AUTO
VARIABLE_SCOPE GLOBAL
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
index 8a897052051..1b26180b710 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
@@ -4399,13 +4399,41 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 10
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
-VARIABLE_COMMENT Number of times the slave SQL thread will retry a transaction in case it failed with a deadlock or elapsed lock wait timeout, before giving up and stopping
+VARIABLE_COMMENT Number of times the slave SQL thread will retry a transaction in case it failed with a deadlock, elapsed lock wait timeout or listed in slave_transaction_retry_errors, before giving up and stopping
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME SLAVE_TRANSACTION_RETRY_ERRORS
+SESSION_VALUE NULL
+GLOBAL_VALUE 1213,1205
+GLOBAL_VALUE_ORIGIN COMPILE-TIME
+DEFAULT_VALUE
+VARIABLE_SCOPE GLOBAL
+VARIABLE_TYPE VARCHAR
+VARIABLE_COMMENT Tells the slave thread to retry transaction for replication when a query event returns an error from the provided list. Deadlock and elapsed lock wait timeout errors are automatically added to this list
+NUMERIC_MIN_VALUE NULL
+NUMERIC_MAX_VALUE NULL
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY YES
+COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME SLAVE_TRANSACTION_RETRY_INTERVAL
+SESSION_VALUE NULL
+GLOBAL_VALUE 0
+GLOBAL_VALUE_ORIGIN COMPILE-TIME
+DEFAULT_VALUE 0
+VARIABLE_SCOPE GLOBAL
+VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_COMMENT Interval of the slave SQL thread will retry a transaction in case it failed with a deadlock or elapsed lock wait timeout or listed in slave_transaction_retry_errors
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 3600
+NUMERIC_BLOCK_SIZE 1
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME SLAVE_TYPE_CONVERSIONS
SESSION_VALUE NULL
GLOBAL_VALUE
diff --git a/mysql-test/suite/sys_vars/t/slave_transaction_retry_errors-master.opt b/mysql-test/suite/sys_vars/t/slave_transaction_retry_errors-master.opt
new file mode 100644
index 00000000000..a93f9f02f70
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_transaction_retry_errors-master.opt
@@ -0,0 +1 @@
+--slave_transaction_retry_errors="10,20, 5000, 400"
diff --git a/mysql-test/suite/sys_vars/t/slave_transaction_retry_errors.test b/mysql-test/suite/sys_vars/t/slave_transaction_retry_errors.test
new file mode 100644
index 00000000000..aa2299cf815
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_transaction_retry_errors.test
@@ -0,0 +1,19 @@
+--source include/not_embedded.inc
+#
+# only global
+#
+select @@global.slave_transaction_retry_errors;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.slave_transaction_retry_errors;
+show global variables like 'slave_transaction_retry_errors';
+show session variables like 'slave_transaction_retry_errors';
+select * from information_schema.global_variables where variable_name='slave_transaction_retry_errors';
+select * from information_schema.session_variables where variable_name='slave_transaction_retry_errors';
+
+#
+# show that it's read-only
+#
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set global slave_transaction_retry_errors=1;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set session slave_transaction_retry_errors=1;
diff --git a/mysql-test/suite/sys_vars/t/slave_transaction_retry_interval_basic.test b/mysql-test/suite/sys_vars/t/slave_transaction_retry_interval_basic.test
new file mode 100644
index 00000000000..4d8d55901d1
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_transaction_retry_interval_basic.test
@@ -0,0 +1,190 @@
+--source include/not_embedded.inc
+#
+# only global
+#
+####### mysql-test\t\slave_transaction_retry_interval_basic.test ##############
+# #
+# Variable Name: slave_transaction_retry_interval #
+# Scope: GLOBAL #
+# Access Type: Dynamic #
+# Data Type: numeric #
+# Default Value: 10 #
+# Range: #
+# #
+# #
+# Creation Date: 2008-02-07 #
+# Author: Rizwan #
+# #
+# Description: Test Cases of Dynamic System Variable #
+# slave_transaction_retry_interval #
+# that checks the behavior of this variable in the following ways#
+# * Default Value #
+# * Valid & Invalid values #
+# * Scope & Access method #
+# * Data Integrity #
+# #
+# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
+# server-system-variables.html #
+# #
+###############################################################################
+
+--source include/not_embedded.inc
+--source include/load_sysvars.inc
+
+###################################################################
+# START OF slave_transaction_retry_interval TESTS #
+###################################################################
+
+
+#############################################################
+# Save initial value #
+#############################################################
+
+SET @start_global_value = @@global.slave_transaction_retry_interval;
+SELECT @start_global_value;
+
+--echo '#--------------------FN_DYNVARS_149_01-------------------------#'
+###################################################################
+# Display the DEFAULT value of slave_transaction_retry_interval #
+###################################################################
+
+SET @@global.slave_transaction_retry_interval = 50;
+SET @@global.slave_transaction_retry_interval = DEFAULT;
+SELECT @@global.slave_transaction_retry_interval;
+
+--echo '#--------------------FN_DYNVARS_149_02-------------------------#'
+###################################################################
+# Check the DEFAULT value of slave_transaction_retry_interval #
+###################################################################
+
+SET @@global.slave_transaction_retry_interval = DEFAULT;
+SELECT @@global.slave_transaction_retry_interval = 10;
+
+--echo '#--------------------FN_DYNVARS_149_03-------------------------#'
+###############################################################################
+# Change the value of slave_transaction_retry_interval to a valid value for
+# GLOBAL Scope
+###############################################################################
+
+SET @@global.slave_transaction_retry_interval = 0;
+SELECT @@global.slave_transaction_retry_interval;
+SET @@global.slave_transaction_retry_interval = 1;
+SELECT @@global.slave_transaction_retry_interval;
+SET @@global.slave_transaction_retry_interval = 15;
+SELECT @@global.slave_transaction_retry_interval;
+SET @@global.slave_transaction_retry_interval = 1024;
+SELECT @@global.slave_transaction_retry_interval;
+SET @@global.slave_transaction_retry_interval = 2147483648;
+SELECT @@global.slave_transaction_retry_interval;
+SET @@global.slave_transaction_retry_interval = 2147483648*2-1;
+SELECT @@global.slave_transaction_retry_interval;
+SET @@global.slave_transaction_retry_interval = 2147483649*2;
+SELECT @@global.slave_transaction_retry_interval;
+SET @@global.slave_transaction_retry_interval = 4294967295;
+SELECT @@global.slave_transaction_retry_interval;
+
+--echo '#--------------------FN_DYNVARS_149_04-------------------------#'
+##############################################################################
+# Check if variable can be access with session scope #
+##############################################################################
+
+--Error ER_GLOBAL_VARIABLE
+SET @@slave_transaction_retry_interval = 2;
+
+--Error ER_GLOBAL_VARIABLE
+SET @@session.slave_transaction_retry_interval = 3;
+
+--Error ER_GLOBAL_VARIABLE
+SET @@local.slave_transaction_retry_interval = 4;
+
+
+--echo '#------------------FN_DYNVARS_149_05-----------------------#'
+############################################################################
+# Change the value of slave_transaction_retry_interval to an invalid value #
+############################################################################
+
+SET @@global.slave_transaction_retry_interval = -1;
+SELECT @@global.slave_transaction_retry_interval;
+
+SET @@global.slave_transaction_retry_interval = 2147483649*2147483649;
+SELECT @@global.slave_transaction_retry_interval;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.slave_transaction_retry_interval = 65530.34;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.slave_transaction_retry_interval = '100';
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.slave_transaction_retry_interval = 7483649.56;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.slave_transaction_retry_interval = ON;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.slave_transaction_retry_interval = OFF;
+
+--echo '#------------------FN_DYNVARS_149_06-----------------------#'
+####################################################################
+# Check if the value in GLOBAL Table matches value in variable #
+####################################################################
+
+SET @@global.slave_transaction_retry_interval = 3000;
+SELECT @@global.slave_transaction_retry_interval = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='slave_transaction_retry_interval';
+
+
+--echo '#------------------FN_DYNVARS_149_07-----------------------#'
+###########################################################################
+# Check if the value is present in INFORMATION_SCHEMA.SESSION_VARIABLES #
+###########################################################################
+
+SELECT count(VARIABLE_VALUE)
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='slave_transaction_retry_interval';
+
+
+--echo '#------------------FN_DYNVARS_149_08-----------------------#'
+####################################################################
+# Check if TRUE and FALSE values can be used on variable #
+####################################################################
+
+SET @@global.slave_transaction_retry_interval = TRUE;
+SELECT @@global.slave_transaction_retry_interval;
+SET @@global.slave_transaction_retry_interval = FALSE;
+SELECT @@global.slave_transaction_retry_interval;
+
+
+--echo '#---------------------FN_DYNVARS_149_09----------------------#'
+###############################################################################
+# Check if accessing variable with and without GLOBAL point to same variable #
+###############################################################################
+
+
+SET @@global.slave_transaction_retry_interval = 60*60;
+SELECT @@slave_transaction_retry_interval = @@global.slave_transaction_retry_interval;
+
+
+--echo '#---------------------FN_DYNVARS_149_10----------------------#'
+###############################################################################
+# Check if slave_transaction_retry_interval can be accessed without @@ sign
+# and scope
+###############################################################################
+
+--Error ER_GLOBAL_VARIABLE
+SET slave_transaction_retry_interval = 2048;
+--Error ER_BAD_FIELD_ERROR
+SELECT slave_transaction_retry_interval;
+
+SELECT @@slave_transaction_retry_interval;
+
+#verifying another another syntax for setting value
+SET global slave_transaction_retry_interval = 99;
+
+####################################
+# Restore initial value #
+####################################
+
+SET @@global.slave_transaction_retry_interval = @start_global_value;
+SELECT @@global.slave_transaction_retry_interval;
+
+########################################################
+# END OF slave_transaction_retry_interval TESTS #
+########################################################
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 4dac2acb5af..c7fbf0a594c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -444,6 +444,7 @@ my_bool opt_replicate_annotate_row_events= 0;
my_bool opt_mysql56_temporal_format=0, strict_password_validation= 1;
my_bool opt_explicit_defaults_for_timestamp= 0;
char *opt_slave_skip_errors;
+char *opt_slave_transaction_retry_errors;
/*
Legacy global handlerton. These will be removed (please do not add more).
@@ -499,6 +500,7 @@ ulong what_to_log;
ulong slow_launch_time;
ulong open_files_limit, max_binlog_size;
ulong slave_trans_retries;
+ulong slave_trans_retry_interval;
uint slave_net_timeout;
ulong slave_exec_mode_options;
ulong slave_run_triggers_for_rbr= 0;
@@ -9638,8 +9640,10 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
flush_time= 0;
#ifdef HAVE_REPLICATION
- if (opt_slave_skip_errors)
- init_slave_skip_errors(opt_slave_skip_errors);
+ if (init_slave_skip_errors(opt_slave_skip_errors))
+ return 1;
+ if (init_slave_transaction_retry_errors(opt_slave_transaction_retry_errors))
+ return 1;
#endif
if (global_system_variables.max_join_size == HA_POS_ERROR)
diff --git a/sql/mysqld.h b/sql/mysqld.h
index e09b6486e02..7a430d4f00b 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -208,6 +208,7 @@ extern my_bool slave_allow_batching;
extern my_bool allow_slave_start;
extern LEX_CSTRING reason_slave_blocked;
extern ulong slave_trans_retries;
+extern ulong slave_trans_retry_interval;
extern uint slave_net_timeout;
extern int max_user_connections;
extern volatile ulong cached_thread_count;
diff --git a/sql/slave.cc b/sql/slave.cc
index 94e35bec4f8..97117656db8 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -72,6 +72,9 @@
bool use_slave_mask = 0;
MY_BITMAP slave_error_mask;
char slave_skip_error_names[SHOW_VAR_FUNC_BUFF_SIZE];
+uint *slave_transaction_retry_errors;
+uint slave_transaction_retry_error_length= 0;
+char slave_transaction_retry_error_names[SHOW_VAR_FUNC_BUFF_SIZE];
char* slave_load_tmpdir = 0;
Master_info *active_mi= 0;
@@ -156,7 +159,8 @@ static bool wait_for_relay_log_space(Relay_log_info* rli);
static bool io_slave_killed(Master_info* mi);
static bool sql_slave_killed(rpl_group_info *rgi);
static int init_slave_thread(THD*, Master_info *, SLAVE_THD_TYPE);
-static void print_slave_skip_errors(void);
+static void make_slave_skip_errors_printable(void);
+static void make_slave_transaction_retry_errors_printable(void);
static int safe_connect(THD* thd, MYSQL* mysql, Master_info* mi);
static int safe_reconnect(THD*, MYSQL*, Master_info*, bool);
static int connect_to_master(THD*, MYSQL*, Master_info*, bool, bool);
@@ -635,7 +639,6 @@ start_slave_background_thread()
sql_print_error("Failed to create thread while initialising slave");
return 1;
}
-
mysql_mutex_lock(&LOCK_slave_background);
while (!slave_background_thread_gtid_loaded)
mysql_cond_wait(&COND_slave_background, &LOCK_slave_background);
@@ -707,15 +710,6 @@ int init_slave()
}
/*
- If --slave-skip-errors=... was not used, the string value for the
- system variable has not been set up yet. Do it now.
- */
- if (!use_slave_mask)
- {
- print_slave_skip_errors();
- }
-
- /*
If master_host is not specified, try to read it from the master_info file.
If master_host is specified, create the master_info file if it doesn't
exists.
@@ -812,12 +806,12 @@ int init_recovery(Master_info* mi, const char** errmsg)
DBUG_RETURN(0);
}
-
+
/**
Convert slave skip errors bitmap into a printable string.
*/
-static void print_slave_skip_errors(void)
+static void make_slave_skip_errors_printable(void)
{
/*
To be safe, we want 10 characters of room in the buffer for a number
@@ -826,7 +820,7 @@ static void print_slave_skip_errors(void)
plus a NUL terminator. That is a max 6 digit number.
*/
const size_t MIN_ROOM= 10;
- DBUG_ENTER("print_slave_skip_errors");
+ DBUG_ENTER("make_slave_skip_errors_printable");
DBUG_ASSERT(sizeof(slave_skip_error_names) > MIN_ROOM);
DBUG_ASSERT(MAX_SLAVE_ERROR <= 999999); // 6 digits
@@ -848,14 +842,14 @@ static void print_slave_skip_errors(void)
else
{
char *buff= slave_skip_error_names;
- char *bend= buff + sizeof(slave_skip_error_names);
+ char *bend= buff + sizeof(slave_skip_error_names) - MIN_ROOM;
int errnum;
for (errnum= 0; errnum < MAX_SLAVE_ERROR; errnum++)
{
if (bitmap_is_set(&slave_error_mask, errnum))
{
- if (buff + MIN_ROOM >= bend)
+ if (buff >= bend)
break; /* purecov: tested */
buff= int10_to_str(errnum, buff, 10);
*buff++= ',';
@@ -885,24 +879,24 @@ static void print_slave_skip_errors(void)
Called from get_options() in mysqld.cc on start-up
*/
-void init_slave_skip_errors(const char* arg)
+bool init_slave_skip_errors(const char* arg)
{
const char *p;
DBUG_ENTER("init_slave_skip_errors");
+ if (!arg || !*arg) // No errors defined
+ goto end;
+
if (my_bitmap_init(&slave_error_mask,0,MAX_SLAVE_ERROR,0))
- {
- fprintf(stderr, "Badly out of memory, please check your system status\n");
- exit(1);
- }
- use_slave_mask = 1;
+ DBUG_RETURN(1);
+
+ use_slave_mask= 1;
for (;my_isspace(system_charset_info,*arg);++arg)
/* empty */;
if (!my_strnncoll(system_charset_info,(uchar*)arg,4,(const uchar*)"all",4))
{
bitmap_set_all(&slave_error_mask);
- print_slave_skip_errors();
- DBUG_VOID_RETURN;
+ goto end;
}
for (p= arg ; *p; )
{
@@ -914,11 +908,109 @@ void init_slave_skip_errors(const char* arg)
while (!my_isdigit(system_charset_info,*p) && *p)
p++;
}
- /* Convert slave skip errors bitmap into a printable string. */
- print_slave_skip_errors();
+
+end:
+ make_slave_skip_errors_printable();
+ DBUG_RETURN(0);
+}
+
+/**
+ Make printable version if slave_transaction_retry_errors
+ This is never empty as at least ER_LOCK_DEADLOCK and ER_LOCK_WAIT_TIMEOUT
+ will be there
+*/
+
+static void make_slave_transaction_retry_errors_printable(void)
+{
+ /*
+ To be safe, we want 10 characters of room in the buffer for a number
+ plus terminators. Also, we need some space for constant strings.
+ 10 characters must be sufficient for a number plus {',' | '...'}
+ plus a NUL terminator. That is a max 6 digit number.
+ */
+ const size_t MIN_ROOM= 10;
+ char *buff= slave_transaction_retry_error_names;
+ char *bend= buff + sizeof(slave_transaction_retry_error_names) - MIN_ROOM;
+ uint i;
+ DBUG_ENTER("make_slave_transaction_retry_errors_printable");
+ DBUG_ASSERT(sizeof(slave_transaction_retry_error_names) > MIN_ROOM);
+
+ /* Make @@slave_transaction_retry_errors show a human-readable value */
+ opt_slave_transaction_retry_errors= slave_transaction_retry_error_names;
+
+ for (i= 0; i < slave_transaction_retry_error_length && buff < bend; i++)
+ {
+ buff= int10_to_str(slave_transaction_retry_errors[i], buff, 10);
+ *buff++= ',';
+ }
+ if (buff != slave_transaction_retry_error_names)
+ buff--; // Remove last ','
+ if (i < slave_transaction_retry_error_length)
+ {
+ /* Couldn't show all errors */
+ buff= strmov(buff, "..."); /* purecov: tested */
+ }
+ *buff=0;
+ DBUG_PRINT("exit", ("error_names: '%s'",
+ slave_transaction_retry_error_names));
DBUG_VOID_RETURN;
}
+
+bool init_slave_transaction_retry_errors(const char* arg)
+{
+ const char *p;
+ long err_code;
+ uint i;
+ DBUG_ENTER("init_slave_transaction_retry_errors");
+
+ /* Handle empty strings */
+ if (!arg)
+ arg= "";
+
+ slave_transaction_retry_error_length= 2;
+ for (;my_isspace(system_charset_info,*arg);++arg)
+ /* empty */;
+ for (p= arg; *p; )
+ {
+ if (!(p= str2int(p, 10, 0, LONG_MAX, &err_code)))
+ break;
+ slave_transaction_retry_error_length++;
+ while (!my_isdigit(system_charset_info,*p) && *p)
+ p++;
+ }
+
+ if (!(slave_transaction_retry_errors=
+ (uint *) my_once_alloc(sizeof(int) *
+ slave_transaction_retry_error_length,
+ MYF(MY_WME))))
+ DBUG_RETURN(1);
+
+ /*
+ Temporary error codes:
+ currently, InnoDB deadlock detected by InnoDB or lock
+ wait timeout (innodb_lock_wait_timeout exceeded
+ */
+ slave_transaction_retry_errors[0]= ER_LOCK_DEADLOCK;
+ slave_transaction_retry_errors[1]= ER_LOCK_WAIT_TIMEOUT;
+
+ /* Add user codes after this */
+ for (p= arg, i= 2; *p; )
+ {
+ if (!(p= str2int(p, 10, 0, LONG_MAX, &err_code)))
+ break;
+ if (err_code > 0 && err_code < ER_ERROR_LAST)
+ slave_transaction_retry_errors[i++]= (uint) err_code;
+ while (!my_isdigit(system_charset_info,*p) && *p)
+ p++;
+ }
+ slave_transaction_retry_error_length= i;
+
+ make_slave_transaction_retry_errors_printable();
+ DBUG_RETURN(0);
+}
+
+
int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
{
DBUG_ENTER("terminate_slave_threads");
@@ -987,7 +1079,7 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
mysql_mutex_unlock(log_lock);
}
- DBUG_RETURN(retval);
+ DBUG_RETURN(retval);
}
@@ -3598,14 +3690,20 @@ static ulong read_event(MYSQL* mysql, Master_info *mi, bool* suppress_warnings,
DBUG_RETURN(len - 1);
}
-/*
+
+/**
Check if the current error is of temporary nature of not.
Some errors are temporary in nature, such as
ER_LOCK_DEADLOCK and ER_LOCK_WAIT_TIMEOUT.
+
+ @retval 0 if fatal error
+ @retval 1 temporary error, do retry
*/
+
int
has_temporary_error(THD *thd)
{
+ uint current_errno;
DBUG_ENTER("has_temporary_error");
DBUG_EXECUTE_IF("all_errors_are_temporary_errors",
@@ -3623,14 +3721,12 @@ has_temporary_error(THD *thd)
if (!thd->is_error())
DBUG_RETURN(0);
- /*
- Temporary error codes:
- currently, InnoDB deadlock detected by InnoDB or lock
- wait timeout (innodb_lock_wait_timeout exceeded
- */
- if (thd->get_stmt_da()->sql_errno() == ER_LOCK_DEADLOCK ||
- thd->get_stmt_da()->sql_errno() == ER_LOCK_WAIT_TIMEOUT)
- DBUG_RETURN(1);
+ current_errno= thd->get_stmt_da()->sql_errno();
+ for (uint i= 0; i < slave_transaction_retry_error_length; i++)
+ {
+ if (current_errno == slave_transaction_retry_errors[i])
+ DBUG_RETURN(1);
+ }
DBUG_RETURN(0);
}
@@ -4281,8 +4377,9 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
exec_res= 0;
serial_rgi->cleanup_context(thd, 1);
/* chance for concurrent connection to get more locks */
- slave_sleep(thd, MY_MIN(serial_rgi->trans_retries,
+ slave_sleep(thd, MY_MAX(MY_MIN(serial_rgi->trans_retries,
MAX_SLAVE_RETRY_PAUSE),
+ slave_trans_retry_interval),
sql_slave_killed, serial_rgi);
serial_rgi->trans_retries++;
mysql_mutex_lock(&rli->data_lock); // because of SHOW STATUS
@@ -4367,7 +4464,7 @@ static bool check_io_slave_killed(Master_info *mi, const char *info)
@param[in] mysql MySQL connection.
@param[in] mi Master connection information.
@param[in,out] retry_count Number of attempts to reconnect.
- @param[in] suppress_warnings TRUE when a normal net read timeout
+ @param[in] suppress_warnings TRUE when a normal net read timeout
has caused to reconnecting.
@param[in] messages Messages to print/log, see
reconnect_messages[] array.
diff --git a/sql/slave.h b/sql/slave.h
index c856a6989ed..74bb4356dfb 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -132,6 +132,9 @@ extern ulong master_retry_count;
extern MY_BITMAP slave_error_mask;
extern char slave_skip_error_names[];
extern bool use_slave_mask;
+extern char slave_transaction_retry_error_names[];
+extern uint *slave_transaction_retry_errors;
+extern uint slave_transaction_retry_error_length;
extern char *slave_load_tmpdir;
extern char *master_info_file;
extern MYSQL_PLUGIN_IMPORT char *relay_log_info_file;
@@ -139,6 +142,7 @@ extern char *opt_relay_logname, *opt_relaylog_index_name;
extern my_bool opt_skip_slave_start, opt_reckless_slave;
extern my_bool opt_log_slave_updates;
extern char *opt_slave_skip_errors;
+extern char *opt_slave_transaction_retry_errors;
extern my_bool opt_replicate_annotate_row_events;
extern ulonglong relay_log_space_limit;
extern ulonglong opt_read_binlog_speed_limit;
@@ -184,7 +188,8 @@ extern const char *relay_log_basename;
int init_slave();
int init_recovery(Master_info* mi, const char** errmsg);
-void init_slave_skip_errors(const char* arg);
+bool init_slave_skip_errors(const char* arg);
+bool init_slave_transaction_retry_errors(const char* arg);
int register_slave_on_master(MYSQL* mysql);
int terminate_slave_threads(Master_info* mi, int thread_mask,
bool skip_lock = 0);
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index b808412f9b1..4b8a712675b 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4872,6 +4872,14 @@ static Sys_var_ulonglong Sys_read_binlog_speed_limit(
GLOBAL_VAR(opt_read_binlog_speed_limit), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1));
+static Sys_var_charptr Sys_slave_transaction_retry_errors(
+ "slave_transaction_retry_errors", "Tells the slave thread to retry "
+ "transaction for replication when a query event returns an error from "
+ "the provided list. Deadlock and elapsed lock wait timeout errors are "
+ "automatically added to this list",
+ READ_ONLY GLOBAL_VAR(opt_slave_transaction_retry_errors), CMD_LINE(REQUIRED_ARG),
+ IN_SYSTEM_CHARSET, DEFAULT(0));
+
static Sys_var_ulonglong Sys_relay_log_space_limit(
"relay_log_space_limit", "Maximum space to use for all relay logs",
READ_ONLY GLOBAL_VAR(relay_log_space_limit), CMD_LINE(REQUIRED_ARG),
@@ -4906,10 +4914,19 @@ static Sys_var_uint Sys_sync_masterinfo_period(
#ifdef HAVE_REPLICATION
static Sys_var_ulong Sys_slave_trans_retries(
"slave_transaction_retries", "Number of times the slave SQL "
- "thread will retry a transaction in case it failed with a deadlock "
- "or elapsed lock wait timeout, before giving up and stopping",
+ "thread will retry a transaction in case it failed with a deadlock, "
+ "elapsed lock wait timeout or listed in "
+ "slave_transaction_retry_errors, before giving up and stopping",
GLOBAL_VAR(slave_trans_retries), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, UINT_MAX), DEFAULT(10), BLOCK_SIZE(1));
+
+static Sys_var_ulong Sys_slave_trans_retry_interval(
+ "slave_transaction_retry_interval", "Interval of the slave SQL "
+ "thread will retry a transaction in case it failed with a deadlock "
+ "or elapsed lock wait timeout or listed in "
+ "slave_transaction_retry_errors",
+ GLOBAL_VAR(slave_trans_retry_interval), CMD_LINE(REQUIRED_ARG),
+ VALID_RANGE(0, 3600), DEFAULT(0), BLOCK_SIZE(1));
#endif
static bool check_locale(sys_var *self, THD *thd, set_var *var)