diff -Narup ./003_mariadb-10.0.15-vp/sql/mysqld.cc ./004_mariadb-10.0.15-slave-trx-retry/sql/mysqld.cc
--- ./003_mariadb-10.0.15-vp/sql/mysqld.cc	2014-11-22 06:02:57.000000000 +0900
+++ ./004_mariadb-10.0.15-slave-trx-retry/sql/mysqld.cc	2014-11-29 17:01:38.858391526 +0900
@@ -425,6 +425,7 @@ my_bool opt_show_slave_auth_info;
 my_bool opt_log_slave_updates= 0;
 my_bool opt_replicate_annotate_row_events= 0;
 char *opt_slave_skip_errors;
+char *opt_slave_transaction_retry_errors;
 
 /*
   Legacy global handlerton. These will be removed (please do not add more).
@@ -484,6 +485,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;
 #ifdef RBR_TRIGGERS
@@ -1990,6 +1992,8 @@ void clean_up(bool print_message)
   end_slave();
   if (use_slave_mask)
     my_bitmap_free(&slave_error_mask);
+  if (slave_transaction_retry_error_length)
+    my_free(slave_transaction_retry_errors);
 #endif
   stop_handle_manager();
   release_ddl_log();
@@ -8865,6 +8869,8 @@ static int get_options(int *argc_ptr, ch
 #ifdef HAVE_REPLICATION
   if (opt_slave_skip_errors)
     init_slave_skip_errors(opt_slave_skip_errors);
+  if (opt_slave_transaction_retry_errors)
+    init_slave_transaction_retry_errors(opt_slave_transaction_retry_errors);
 #endif
 
   if (global_system_variables.max_join_size == HA_POS_ERROR)
diff -Narup ./003_mariadb-10.0.15-vp/sql/mysqld.h ./004_mariadb-10.0.15-slave-trx-retry/sql/mysqld.h
--- ./003_mariadb-10.0.15-vp/sql/mysqld.h	2014-11-22 06:02:53.000000000 +0900
+++ ./004_mariadb-10.0.15-slave-trx-retry/sql/mysqld.h	2014-11-29 17:01:38.859797153 +0900
@@ -172,6 +172,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 ulong what_to_log,flush_time;
diff -Narup ./003_mariadb-10.0.15-vp/sql/slave.cc ./004_mariadb-10.0.15-slave-trx-retry/sql/slave.cc
--- ./003_mariadb-10.0.15-vp/sql/slave.cc	2014-11-22 06:02:56.000000000 +0900
+++ ./004_mariadb-10.0.15-slave-trx-retry/sql/slave.cc	2014-11-29 17:01:39.321379623 +0900
@@ -70,6 +70,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;
@@ -151,6 +154,7 @@ static bool sql_slave_killed(rpl_group_i
 static int init_slave_thread(THD* thd, Master_info *mi,
                              SLAVE_THD_TYPE thd_type);
 static void print_slave_skip_errors(void);
+static void print_slave_transaction_retry_errors(void);
 static int safe_connect(THD* thd, MYSQL* mysql, Master_info* mi);
 static int safe_reconnect(THD* thd, MYSQL* mysql, Master_info* mi,
                           bool suppress_warnings);
@@ -415,6 +419,8 @@ int init_slave()
   {
     print_slave_skip_errors();
   }
+  if (!slave_transaction_retry_error_length)
+    print_slave_transaction_retry_errors();
 
   /*
     If master_host is not specified, try to read it from the master_info file.
@@ -612,6 +618,94 @@ void init_slave_skip_errors(const char* 
   DBUG_VOID_RETURN;
 }
 
+static void print_slave_transaction_retry_errors(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;
+  DBUG_ENTER("print_slave_transaction_retry_errors");
+  DBUG_ASSERT(sizeof(slave_transaction_retry_error_names) > MIN_ROOM);
+
+  if (!slave_transaction_retry_error_length)
+  {
+    /* purecov: begin tested */
+    memcpy(slave_transaction_retry_error_names, STRING_WITH_LEN("OFF"));
+    /* purecov: end */
+  }
+  else
+  {
+    char *buff= slave_transaction_retry_error_names;
+    char *bend= buff + sizeof(slave_transaction_retry_error_names);
+    uint  i;
+
+    for (i= 0; i < slave_transaction_retry_error_length; i++)
+    {
+      if (buff + MIN_ROOM >= bend)
+        break; /* purecov: tested */
+      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("init", ("error_names: '%s'", slave_transaction_retry_error_names));
+  DBUG_VOID_RETURN;
+}
+
+void init_slave_transaction_retry_errors(const char* arg)
+{
+  const char *p;
+  long err_code;
+  DBUG_ENTER("init_slave_transaction_retry_errors");
+
+  slave_transaction_retry_error_length= 0;
+  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_error_length)
+  {
+    if (!(slave_transaction_retry_errors= (uint *) my_malloc(
+      sizeof(int) * slave_transaction_retry_error_length, MYF(MY_WME))))
+    {
+      fprintf(stderr,
+        "Badly out of memory, please check your system status\n");
+      exit(1);
+    }
+
+    int i;
+    for (p= arg, i= 0; *p; i++)
+    {
+      if (!(p= str2int(p, 10, 0, LONG_MAX, &err_code)))
+        break;
+      slave_transaction_retry_errors[i]= (uint) err_code;
+      while (!my_isdigit(system_charset_info,*p) && *p)
+        p++;
+    }
+  } else
+    slave_transaction_retry_errors= NULL;
+  /* Convert slave transaction retry errors into a printable string. */
+  print_slave_transaction_retry_errors();
+  DBUG_VOID_RETURN;
+}
+
 int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
 {
   DBUG_ENTER("terminate_slave_threads");
@@ -3158,6 +3252,13 @@ has_temporary_error(THD *thd)
       thd->get_stmt_da()->sql_errno() == ER_LOCK_WAIT_TIMEOUT)
     DBUG_RETURN(1);
 
+  uint i;
+  for (i= 0; i < slave_transaction_retry_error_length; i++)
+  {
+    if (thd->get_stmt_da()->sql_errno() == slave_transaction_retry_errors[i])
+      DBUG_RETURN(1);
+  }
+
 #ifdef HAVE_NDB_BINLOG
   /*
     currently temporary error set in ndbcluster
@@ -3630,8 +3731,9 @@ static int exec_relay_log_event(THD* thd
             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
diff -Narup ./003_mariadb-10.0.15-vp/sql/slave.h ./004_mariadb-10.0.15-slave-trx-retry/sql/slave.h
--- ./003_mariadb-10.0.15-vp/sql/slave.h	2014-11-22 06:02:53.000000000 +0900
+++ ./004_mariadb-10.0.15-slave-trx-retry/sql/slave.h	2014-11-29 17:01:40.359580132 +0900
@@ -121,6 +121,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;
@@ -128,6 +131,7 @@ extern char *opt_relay_logname, *opt_rel
 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;
 
@@ -169,6 +173,7 @@ extern ulonglong relay_log_space_limit;
 int init_slave();
 int init_recovery(Master_info* mi, const char** errmsg);
 void init_slave_skip_errors(const char* arg);
+void init_slave_transaction_retry_errors(const char* arg);
 bool flush_relay_log_info(Relay_log_info* rli);
 int register_slave_on_master(MYSQL* mysql);
 int terminate_slave_threads(Master_info* mi, int thread_mask,
diff -Narup ./003_mariadb-10.0.15-vp/sql/sys_vars.cc ./004_mariadb-10.0.15-slave-trx-retry/sql/sys_vars.cc
--- ./003_mariadb-10.0.15-vp/sql/sys_vars.cc	2014-11-22 06:02:53.000000000 +0900
+++ ./004_mariadb-10.0.15-slave-trx-retry/sql/sys_vars.cc	2014-11-29 17:01:41.024408957 +0900
@@ -4341,6 +4341,13 @@ static Sys_var_charptr Sys_slave_skip_er
        READ_ONLY GLOBAL_VAR(opt_slave_skip_errors), CMD_LINE(REQUIRED_ARG),
        IN_SYSTEM_CHARSET, DEFAULT(0));
 
+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",
+       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),
@@ -4379,6 +4386,13 @@ static Sys_var_ulong Sys_slave_trans_ret
        "or elapsed lock wait timeout, 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",
+       GLOBAL_VAR(slave_trans_retry_interval), CMD_LINE(REQUIRED_ARG),
+       VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1));
 #endif
 
 static bool check_locale(sys_var *self, THD *thd, set_var *var)
