[Commits] Rev 4509: MDEV-6676: Speculative parallel replication: Intermediate commit. in http://bazaar.launchpad.net/~maria-captains/maria/10.0

knielsen at knielsen-hq.org knielsen at knielsen-hq.org
Thu Nov 13 16:26:12 EET 2014

At http://bazaar.launchpad.net/~maria-captains/maria/10.0

revno: 4509
revision-id: knielsen at knielsen-hq.org-20141008075652-w43eeqof3tbofett
parent: knielsen at knielsen-hq.org-20141007142037-jtnbu1odotyr72ye
committer: Kristian Nielsen <knielsen at knielsen-hq.org>
branch nick: work-10.0-mdev6676
timestamp: Wed 2014-10-08 09:56:52 +0200
  MDEV-6676: Speculative parallel replication: Intermediate commit.
  Add an extra flag FL_DDL to the GTID event created on the master.
  This allows the parallel slave to distinguish between DDL and
  non-transactional DML.
  In case of DDL, it is not safe to run anything in parallel speculatively,
  neither prior or following transactions. Not prior, because DDL cannot be
  rolled back in case of conflicts. And not following, for example the DDL might
  convert a non-transactional table into a transactional one, so this conversion
  must be completed before a later transaction can be safely rolled back in case
  of conflicts.
  In case of non-transactional DML, it is also not safe to run it in parallel
  with earlier transactions, since in case of conflicts it can not be rolled
  back. But it _is_ safe to run it in parallel with later transactions.
  Relaxing the requirements for non-transactional DML is beneficial when a few
  non-transactional events occur in a stream of transactional DML, as would be a
  typical use case. This way, the parallel apply of the transactional DML is not
  disturbed or hindered. Before this commit, every non-transactional DML would
  require first all running transactions to reach their commit phase, and only
  then could following transactions start. With this commit, now following
  transactions can be freely applied in parallel optimistically. Only the single
  thread for which the non-transactional DML is scheduled needs to wait.
  The non-transactional DML will not be able to grup-commit together with the
  prior transaction, as the wait is done with wait_for_prior_commit().
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2014-10-07 14:20:37 +0000
+++ b/sql/log_event.cc	2014-10-08 07:56:52 +0000
@@ -6415,8 +6415,9 @@ Gtid_log_event::Gtid_log_event(THD *thd_
   if (thd_arg->transaction.stmt.trans_did_wait() ||
     flags2|= FL_WAITED;
-  if (is_transactional &&
-      !(sql_command_flags[thd->lex->sql_command] & CF_DISALLOW_IN_RO_TRANS))
+  if (sql_command_flags[thd->lex->sql_command] & CF_DISALLOW_IN_RO_TRANS)
+    flags2|= FL_DDL;
+  else if (is_transactional)
     flags2|= FL_TRANSACTIONAL;
   if (thd_arg->variables.option_bits & OPTION_RPL_ALLOW_PARALLEL)
     flags2|= FL_ALLOW_PARALLEL;
@@ -6634,6 +6635,8 @@ Gtid_log_event::print(FILE *file, PRINT_
       longlong10_to_str(commit_id, buf2, 10);
       my_b_printf(&cache, " cid=%s", buf2);
+    if (flags2 & FL_DDL)
+      my_b_write_string(&cache, " ddl");
     if (flags2 & FL_TRANSACTIONAL)
       my_b_write_string(&cache, " trans");
     if (flags2 & FL_WAITED)

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2014-09-17 12:37:39 +0000
+++ b/sql/log_event.h	2014-10-08 07:56:52 +0000
@@ -3169,7 +3169,7 @@ class Gtid_log_event: public Log_event
   static const uchar FL_GROUP_COMMIT_ID= 2;
     FL_TRANSACTIONAL is set for an event group that can be safely rolled back
-    (no DDL or MyISAM, eg.).
+    (no MyISAM, eg.).
   static const uchar FL_TRANSACTIONAL= 4;
@@ -3182,6 +3182,8 @@ class Gtid_log_event: public Log_event
     execution of the transaction.
   static const uchar FL_WAITED= 16;
+  /* FL_DDL is set for event group containing DDL. */
+  static const uchar FL_DDL= 32;
   Gtid_log_event(THD *thd_arg, uint64 seq_no, uint32 domain_id, bool standalone,

=== modified file 'sql/rpl_parallel.cc'
--- a/sql/rpl_parallel.cc	2014-10-07 14:20:37 +0000
+++ b/sql/rpl_parallel.cc	2014-10-08 07:56:52 +0000
@@ -2068,7 +2068,7 @@ rpl_parallel::do_event(rpl_group_info *s
           e->last_commit_id != gtid_ev->commit_id)
         flags|= group_commit_orderer::MULTI_BATCH;
       /* Make sure we do not attempt to run DDL in parallel speculatively. */
-      if (!(gtid_flags & Gtid_log_event::FL_TRANSACTIONAL)/* ToDo: use a new flag "FL_DDL" here. */)
+      if (!(gtid_flags & Gtid_log_event::FL_DDL))
         flags|= (force_switch_flag= group_commit_orderer::FORCE_SWITCH);
       if (!(flags & group_commit_orderer::MULTI_BATCH))

More information about the commits mailing list