diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2019-12-03 14:45:06 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2019-12-03 14:45:06 +0100 |
commit | f8b5e147da18d0baa7345aed0deec0fd40666d19 (patch) | |
tree | c0b0cbb9bc0f5afd6ca123604a67323bdc521099 /sql/wsrep_mysqld.cc | |
parent | 543f22a2d0633e645fb49a360c55528d8cb008fb (diff) | |
parent | 117c8146de7ccfaf2331225d6fb264de71aa6779 (diff) | |
download | mariadb-git-f8b5e147da18d0baa7345aed0deec0fd40666d19.tar.gz |
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/wsrep_mysqld.cc')
-rw-r--r-- | sql/wsrep_mysqld.cc | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 5e2e48fd15d..062c9dcd74c 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -37,7 +37,6 @@ #include <cstdio> #include <cstdlib> #include "log_event.h" -#include <slave.h> #include "sql_plugin.h" /* wsrep_plugins_pre_init() */ #include <vector> @@ -1544,6 +1543,39 @@ static bool wsrep_can_run_in_toi(THD *thd, const char *db, const char *table, { return false; } + /* + If mariadb master has replicated a CTAS, we should not replicate the create table + part separately as TOI, but to replicate both create table and following inserts + as one write set. + Howver, if CTAS creates empty table, we should replicate the create table alone + as TOI. We have to do relay log event lookup to see if row events follow the + create table event. + */ + if (thd->slave_thread && !(thd->rgi_slave->gtid_ev_flags2 & Gtid_log_event::FL_STANDALONE)) + { + /* this is CTAS, either empty or populated table */ + ulonglong event_size = 0; + enum Log_event_type ev_type= wsrep_peak_event(thd->rgi_slave, &event_size); + switch (ev_type) + { + case QUERY_EVENT: + /* CTAS with empty table, we replicate create table as TOI */ + break; + + case TABLE_MAP_EVENT: + WSREP_DEBUG("replicating CTAS of empty table as TOI"); + // fall through + case WRITE_ROWS_EVENT: + /* CTAS with populated table, we replicate later at commit time */ + WSREP_DEBUG("skipping create table of CTAS replication"); + return false; + + default: + WSREP_WARN("unexpected async replication event: %d", ev_type); + } + return true; + } + /* no next async replication event */ return true; case SQLCOM_CREATE_VIEW: |