summaryrefslogtreecommitdiff
path: root/sql/sql_repl.cc
diff options
context:
space:
mode:
authorSachin <sachin.setiya@mariadb.com>2020-06-11 13:33:48 +0530
committerSachin Kumar <sachin.setiya@mariadb.com>2021-05-25 14:03:52 +0100
commitdb02338ed6189a3b40307cb58bcc469b189cab5d (patch)
treec2501cf0092365e438fbab4efcfdb1681c250cb0 /sql/sql_repl.cc
parente607f3398c69147299884d3814cf063d2e7516ce (diff)
downloadmariadb-git-bb-10.2-sachin.tar.gz
MDEV-19157 Optimistic Parallel Replication fails when gtid_slave_pos table is non transnational and binlog events are transnationalbb-10.2-sachin
Problem:- In Optimistic/Aggressive mode of parallel replication when we have conflict, we retry the transaction, But if gtid_slave_pos is non transactional In that case retry may result into duplicate key error for table because the conflicted transaction can not rollback the changes in gtid_slave_pos table So when we try the same trans again, We get the Duplicate Key error Solution:- Users are advised to use transactional storage engine for gtid_slave_pos. In this patch we are throwing warning when we see that gtid_slave_pos in non transactional. In addition to throwing warnings Transactional event groups from master are not scheduled in Optimistic/Aggressive mode.
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r--sql/sql_repl.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 7ff0e27b008..42531d8d6e6 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -15,6 +15,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#include <my_global.h>
+#include "mysqld.h"
#include "sql_priv.h"
#include "unireg.h"
#include "sql_base.h"
@@ -3163,6 +3164,27 @@ int start_slave(THD* thd , Master_info* mi, bool net_report)
Sql_condition::WARN_LEVEL_NOTE, ER_UNTIL_COND_IGNORED,
ER_THD(thd, ER_UNTIL_COND_IGNORED));
+ int result= mysql_gtid_slave_pos_transactional(thd);
+ if(result)
+ {
+ slave_errno= result;
+ goto err;
+ }
+ if(!(rpl_global_gtid_slave_state->gtid_slave_pos_transactional_cache)&&
+ mi->parallel_mode > SLAVE_PARALLEL_CONSERVATIVE &&
+ opt_slave_parallel_threads > 1)
+ {
+ const char *mode= mi->parallel_mode == SLAVE_PARALLEL_OPTIMISTIC ?
+ "Optimistic" : "Aggressive";
+ sql_print_warning("Non transactional gtid_slave_pos table with %s "
+ "parallel mode detected, Transactions will be applied "
+ "in conservative mode.", mode);
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_GTID_SLAVE_POS_NON_TRANS,
+ ER_THD(thd, ER_GTID_SLAVE_POS_NON_TRANS),
+ mode);
+ }
+
if (!slave_errno)
slave_errno = start_slave_threads(thd,
1,