summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2014-10-08 18:47:16 +0200
committerSergei Golubchik <serg@mariadb.org>2014-10-10 22:27:36 +0200
commit03ec3511a82e90310c850ea71b395b214cab1645 (patch)
tree65e6b3dea94e4744b5b9a3bfb0f847977ed7d55a
parent8596b70f96fc543c2e1cac4bc8cbe58dcc4004e5 (diff)
downloadmariadb-git-03ec3511a82e90310c850ea71b395b214cab1645.tar.gz
cleanup: galera misc cleanups
also disable galera-specific output in mysql_tzinfo_to_sql, it'll be enabled later.
-rw-r--r--client/mysql_upgrade.c11
-rw-r--r--client/mysqlcheck.c9
-rw-r--r--mysql-test/r/mysql_tzinfo_to_sql_symlink.result17
-rw-r--r--mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result70
-rw-r--r--mysql-test/suite/wsrep/suite.pm9
-rw-r--r--mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test41
-rw-r--r--mysql-test/t/mysql_tzinfo_to_sql_symlink.test6
-rw-r--r--mysys/my_static.c4
-rw-r--r--mysys/mysys_priv.h2
-rw-r--r--mysys/thr_lock.c8
-rw-r--r--sql/event_parse_data.cc3
-rw-r--r--sql/events.cc17
-rw-r--r--sql/handler.cc73
-rw-r--r--sql/log.cc3
-rw-r--r--sql/slave.cc5
-rw-r--r--sql/sql_acl.cc57
-rw-r--r--sql/sql_base.cc53
-rw-r--r--sql/sql_parse.cc18
-rw-r--r--sql/tztime.cc10
-rw-r--r--sql/wsrep_hton.cc5
-rw-r--r--sql/wsrep_mysqld.cc6
-rw-r--r--sql/wsrep_mysqld.h1
-rw-r--r--sql/wsrep_thd.h5
23 files changed, 149 insertions, 284 deletions
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index bf33397efdb..65ea586c672 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -524,7 +524,16 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
File fd;
char query_file_path[FN_REFLEN];
#ifdef WITH_WSREP
- /* Note: wsrep_on=ON implicitly enables binary logging. */
+ /*
+ Strictly speaking, WITH_WSREP on the client only means that the
+ client was compiled with WSREP, it doesn't mean the server was,
+ so the server might not have WSREP_ON variable.
+
+ But mysql_upgrade is tightly bound to a specific server version
+ anyway - it was mysql_fix_privilege_tables_sql script embedded
+ into its binary - so even if it won't assume anything about server
+ wsrep-ness, it won't be any less server-dependend.
+ */
const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0, WSREP_ON=OFF;";
#else
const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0;";
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index f7ae0783e5e..fc196d2f27a 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -734,13 +734,8 @@ static int use_db(char *database)
/* Do not send commands to replication slaves. */
static int disable_binlog()
{
-#ifdef WITH_WSREP
- /* Additionally turn off @@wsrep_on to disable implicit binary logging. */
- const char *stmt= "SET SQL_LOG_BIN=0, WSREP_ON=OFF";
-#else
- const char *stmt= "SET SQL_LOG_BIN=0";
-#endif /* WITH_WSREP */
- return run_query(stmt);
+ mysql_query(sock, "SET WSREP_ON=0"); /* ignore the error, if any */
+ return run_query("SET SQL_LOG_BIN=0");
}
static int handle_request_for_tables(char *tables, uint length)
diff --git a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result
index 484f71a4c2e..c00a0c73ce3 100644
--- a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result
+++ b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result
@@ -1,8 +1,10 @@
#
# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
#
-SET SESSION wsrep_replicate_myisam=ON;
# Verbose run
+set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
+prepare set_wsrep_myisam from @prep;
+set @toggle=1; execute set_wsrep_myisam using @toggle;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -26,7 +28,11 @@ Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zo
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
+set @toggle=0; execute set_wsrep_myisam using @toggle;
# Silent run
+set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
+prepare set_wsrep_myisam from @prep;
+set @toggle=1; execute set_wsrep_myisam using @toggle;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -47,17 +53,26 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
+set @toggle=0; execute set_wsrep_myisam using @toggle;
#
# Testing with explicit timezonefile
#
+set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
+prepare set_wsrep_myisam from @prep;
+set @toggle=1; execute set_wsrep_myisam using @toggle;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
+set @toggle=0; execute set_wsrep_myisam using @toggle;
#
# Testing --leap
#
+set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
+prepare set_wsrep_myisam from @prep;
+set @toggle=1; execute set_wsrep_myisam using @toggle;
TRUNCATE TABLE time_zone_leap_second;
ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
+set @toggle=0; execute set_wsrep_myisam using @toggle;
diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result
deleted file mode 100644
index f77a655773a..00000000000
--- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
-#
-# Verbose run
-SET GLOBAL wsrep_replicate_myisam= ON;
-TRUNCATE TABLE time_zone;
-TRUNCATE TABLE time_zone_name;
-TRUNCATE TABLE time_zone_transition;
-TRUNCATE TABLE time_zone_transition_type;
-INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
-SET @time_zone_id= LAST_INSERT_ID();
-INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
-INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
- (@time_zone_id, 0, 0, 0, 'GMT')
-;
-Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it.
-Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/ignored.tab' as time zone. Skipping it.
-INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
-SET @time_zone_id= LAST_INSERT_ID();
-INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id);
-INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
- (@time_zone_id, 0, 0, 0, 'GMT')
-;
-Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
-Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it.
-Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
-ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
-ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
-SET GLOBAL wsrep_replicate_myisam= OFF;
-# Silent run
-SET GLOBAL wsrep_replicate_myisam= ON;
-TRUNCATE TABLE time_zone;
-TRUNCATE TABLE time_zone_name;
-TRUNCATE TABLE time_zone_transition;
-TRUNCATE TABLE time_zone_transition_type;
-INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
-SET @time_zone_id= LAST_INSERT_ID();
-INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
-INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
- (@time_zone_id, 0, 0, 0, 'GMT')
-;
-Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it.
-INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
-SET @time_zone_id= LAST_INSERT_ID();
-INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id);
-INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
- (@time_zone_id, 0, 0, 0, 'GMT')
-;
-Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
-ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
-ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
-SET GLOBAL wsrep_replicate_myisam= OFF;
-#
-# Testing with explicit timezonefile
-#
-SET GLOBAL wsrep_replicate_myisam= ON;
-INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
-SET @time_zone_id= LAST_INSERT_ID();
-INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id);
-INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
- (@time_zone_id, 0, 0, 0, 'GMT')
-;
-SET GLOBAL wsrep_replicate_myisam= OFF;
-#
-# Testing --leap
-#
-SET GLOBAL wsrep_replicate_myisam= ON;
-TRUNCATE TABLE time_zone_leap_second;
-ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
-SET GLOBAL wsrep_replicate_myisam= OFF;
diff --git a/mysql-test/suite/wsrep/suite.pm b/mysql-test/suite/wsrep/suite.pm
index bcd7e6f3813..e22ba43e90a 100644
--- a/mysql-test/suite/wsrep/suite.pm
+++ b/mysql-test/suite/wsrep/suite.pm
@@ -16,9 +16,11 @@ return "No wsrep provider library" unless -f $provider;
$ENV{WSREP_PROVIDER} = $provider;
-my ($path) = grep { -f "$_/wsrep_sst_rsync"; } "$::bindir/scripts", $::path_client_bindir;
+my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$::bindir/scripts", $::path_client_bindir;
+return "No SST scripts" unless $spath;
-return "No SST scripts" unless $path;
+my ($epath) = grep { -f "$_/my_print_defaults"; } "$::bindir/extra", $::path_client_bindir;
+return "No my_print_defaults" unless $epath;
push @::global_suppressions,
(
@@ -32,7 +34,8 @@ push @::global_suppressions,
);
-$ENV{PATH}="$path:$ENV{PATH}";
+$ENV{PATH}="$epath:$ENV{PATH}";
+$ENV{PATH}="$spath:$ENV{PATH}" unless $epath eq $spath;
bless { };
diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test
deleted file mode 100644
index 87554635666..00000000000
--- a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test
+++ /dev/null
@@ -1,41 +0,0 @@
---source include/have_wsrep.inc
---source include/have_symlink.inc
---source include/not_windows.inc
---source include/have_innodb.inc
-
---echo #
---echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
---echo #
-
---exec mkdir $MYSQLTEST_VARDIR/zoneinfo
---exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix
---copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT
---copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/garbage
---copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/ignored.tab
-
---echo # Verbose run
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_TZINFO_TO_SQL --verbose $MYSQLTEST_VARDIR/zoneinfo 2>&1
-
---echo # Silent run
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1
-
---echo #
---echo # Testing with explicit timezonefile
---echo #
-
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1
-
---echo #
---echo # Testing --leap
---echo #
-
---exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1
-
-#
-# Cleanup
-#
-
---exec rm -rf $MYSQLTEST_VARDIR/zoneinfo
diff --git a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test
index 13a4eaaf605..1ba4e91be3c 100644
--- a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test
+++ b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test
@@ -1,11 +1,5 @@
--source include/have_symlink.inc
--source include/not_windows.inc
---source include/not_wsrep.inc
-
-# Note: The output of mysql_tzinfo_to_sql is different if server is compiled
-# with wsrep. Hence a copy of this test has been placed under wsrep suite with
-# the updated result. (lp:1161432)
---source include/not_wsrep.inc
--echo #
--echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 4c977837e05..84d2dc64fc6 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -68,10 +68,6 @@ uint my_large_page_size= 0;
int volatile my_have_got_alarm=0; /* declare variable to reset */
ulong my_time_to_wait_for_lock=2; /* In seconds */
-#ifdef WITH_WSREP
-my_bool mysys_wsrep= 0;
-#endif
-
/* from errors.c */
#ifdef SHARED_LIBRARY
const char *globerrs[GLOBERRS]; /* my_error_messages is here */
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index 9b94a5a18ce..4ea6d081107 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -62,8 +62,6 @@ extern mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;
extern mysql_mutex_t THR_LOCK_lock, THR_LOCK_net;
extern mysql_mutex_t THR_LOCK_charset;
-extern my_bool mysys_wsrep;
-
#include <mysql/psi/mysql_file.h>
#ifdef HAVE_PSI_INTERFACE
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index cd30c30afea..bb16ba92088 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -688,7 +688,7 @@ wsrep_break_lock(
THR_LOCK_DATA *data, struct st_lock_list *lock_queue1,
struct st_lock_list *wait_queue)
{
- if (wsrep_on(data->owner->mysql_thd) &&
+ if (wsrep_on && wsrep_on(data->owner->mysql_thd) &&
wsrep_thd_is_brute_force &&
wsrep_thd_is_brute_force(data->owner->mysql_thd, TRUE))
{
@@ -858,7 +858,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
In the latter case we should yield the lock to the writer.
*/
#ifdef WITH_WSREP
- if (mysys_wsrep && wsrep_break_lock(data, &lock->write, &lock->read_wait))
+ if (wsrep_break_lock(data, &lock->write, &lock->read_wait))
{
wsrep_lock_inserted= TRUE;
}
@@ -1006,7 +1006,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
lock->read.data->owner->thread_id, data->type));
}
#ifdef WITH_WSREP
- if (mysys_wsrep && wsrep_break_lock(data, &lock->write, &lock->write_wait))
+ if (wsrep_break_lock(data, &lock->write, &lock->write_wait))
{
wsrep_lock_inserted= TRUE;
}
@@ -1016,7 +1016,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
}
/* Can't get lock yet; Wait for it */
#ifdef WITH_WSREP
- if (mysys_wsrep && wsrep_lock_inserted && wsrep_on(data->owner->mysql_thd))
+ if (wsrep_lock_inserted && wsrep_on(data->owner->mysql_thd))
DBUG_RETURN(wait_for_lock(wait_queue, data, 1, lock_wait_timeout));
#endif
result= wait_for_lock(wait_queue, data, 0, lock_wait_timeout);
diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc
index 7647419aff9..44d89887c3b 100644
--- a/sql/event_parse_data.cc
+++ b/sql/event_parse_data.cc
@@ -564,7 +564,8 @@ Event_parse_data::init_definer(THD *thd)
void Event_parse_data::check_originator_id(THD *thd)
{
/* Disable replicated events on slave. */
- if ((thd->system_thread == SYSTEM_THREAD_SLAVE_SQL) ||
+ if (IF_WSREP(WSREP(thd) && thd->wsrep_applier, 0) ||
+ (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL) ||
(thd->system_thread == SYSTEM_THREAD_SLAVE_IO))
{
DBUG_PRINT("info", ("Invoked object status set to SLAVESIDE_DISABLED."));
diff --git a/sql/events.cc b/sql/events.cc
index d42a5d7b0a0..7c6b29b7604 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -1130,23 +1130,6 @@ Events::load_events_from_db(THD *thd)
delete et;
goto end;
}
-#ifdef WITH_WSREP
- /*
- When SST from master node who initials event, the event status is ENABLED
- this is problematic because there are two nodes with same events and
- both enabled.
- */
- if (WSREP(thd) && et->originator != thd->variables.server_id)
- {
- store_record(table, record[1]);
- table->field[ET_FIELD_STATUS]->
- store((longlong) Event_parse_data::SLAVESIDE_DISABLED,
- TRUE);
- (void) table->file->ha_update_row(table->record[1], table->record[0]);
- delete et;
- continue;
- }
-#endif
/**
Since the Event_queue_element object could be deleted inside
Event_queue::create_event we should save the value of dropped flag
diff --git a/sql/handler.cc b/sql/handler.cc
index 68762061053..42f5f7ac442 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1144,6 +1144,25 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg)
DBUG_VOID_RETURN;
}
+
+static int prepare_or_error(handlerton *ht, THD *thd, bool all)
+{
+ int err= ht->prepare(ht, thd, all);
+ status_var_increment(thd->status_var.ha_prepare_count);
+ if (err)
+ {
+ /* avoid sending error, if we're going to replay the transaction */
+#ifdef WITH_WSREP
+ if (ht == wsrep_hton &&
+ err != WSREP_TRX_SIZE_EXCEEDED &&
+ thd->wsrep_conflict_state != MUST_REPLAY)
+#endif
+ my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
+ }
+ return err;
+}
+
+
/**
@retval
0 ok
@@ -1161,32 +1180,14 @@ int ha_prepare(THD *thd)
{
for (; ha_info; ha_info= ha_info->next())
{
- int err;
handlerton *ht= ha_info->ht();
- status_var_increment(thd->status_var.ha_prepare_count);
if (ht->prepare)
{
- if ((err= ht->prepare(ht, thd, all)))
+ if (prepare_or_error(ht, thd, all))
{
-#ifdef WITH_WSREP
- if (ht == wsrep_hton)
- {
- error= 1;
- /* avoid sending error, if we need to replay */
- if (thd->wsrep_conflict_state!= MUST_REPLAY)
- {
- my_error(ER_LOCK_DEADLOCK, MYF(0), err);
- }
- }
- else
-#endif
- {
- /* not wsrep hton, bail to native mysql behavior */
- my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
- ha_rollback_trans(thd, all);
- error=1;
- break;
- }
+ ha_rollback_trans(thd, all);
+ error=1;
+ break;
}
}
else
@@ -1417,7 +1418,6 @@ int ha_commit_trans(THD *thd, bool all)
for (Ha_trx_info *hi= ha_info; hi; hi= hi->next())
{
- int err;
handlerton *ht= hi->ht();
/*
Do not call two-phase commit if this particular
@@ -1430,32 +1430,9 @@ int ha_commit_trans(THD *thd, bool all)
Sic: we know that prepare() is not NULL since otherwise
trans->no_2pc would have been set.
*/
- err= ht->prepare(ht, thd, all);
- status_var_increment(thd->status_var.ha_prepare_count);
- if (err)
- {
-#ifdef WITH_WSREP
- if (ht == wsrep_hton)
- {
- switch (err) {
- case WSREP_TRX_SIZE_EXCEEDED:
- /* give user size exeeded error from wsrep_api.h */
- my_error(ER_ERROR_DURING_COMMIT, MYF(0), WSREP_SIZE_EXCEEDED);
- break;
- case WSREP_TRX_CERT_FAIL:
- case WSREP_TRX_ERROR:
- /* avoid sending error, if we need to replay */
- if (thd->wsrep_conflict_state!= MUST_REPLAY)
- {
- my_error(ER_LOCK_DEADLOCK, MYF(0), err);
- }
- }
- goto err;
- }
-#endif /* WITH_WSREP */
- my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
+ if (prepare_or_error(ht, thd, all))
goto err;
- }
+
need_prepare_ordered|= (ht->prepare_ordered != NULL);
need_commit_ordered|= (ht->commit_ordered != NULL);
}
diff --git a/sql/log.cc b/sql/log.cc
index a9ba0c4eb32..e0fd74b5e38 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2230,8 +2230,7 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
DBUG_RETURN(mysql_bin_log.write(&qinfo));
}
- if (!wsrep_emulate_bin_log)
- binlog_trans_log_truncate(thd, *(my_off_t*)sv);
+ binlog_trans_log_truncate(thd, *(my_off_t*)sv);
DBUG_RETURN(0);
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 110283ce4b4..3241f3fc117 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -4368,7 +4368,7 @@ pthread_handler_t handle_slave_sql(void *arg)
my_off_t saved_skip= 0;
Master_info *mi= ((Master_info*)arg);
Relay_log_info* rli = &mi->rli;
- my_bool wsrep_node_dropped= FALSE;
+ my_bool wsrep_node_dropped __attribute__((unused)) = FALSE;
const char *errmsg;
rpl_group_info *serial_rgi;
rpl_sql_thread_info sql_info(mi->rpl_filter);
@@ -4379,9 +4379,6 @@ pthread_handler_t handle_slave_sql(void *arg)
wsrep_restart_point:
- LINT_INIT(saved_master_log_pos);
- LINT_INIT(saved_log_pos);
-
serial_rgi= new rpl_group_info(rli);
thd = new THD; // note that contructor of THD uses DBUG_ !
thd->thread_stack = (char*)&thd; // remember where our stack is
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 8e976f0f579..b922eead8ea 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -2655,11 +2655,11 @@ bool change_password(THD *thd, const char *host, const char *user,
TABLE_LIST tables[TABLES_MAX];
/* Buffer should be extended when password length is extended. */
char buff[512];
- ulong query_length=0;
+ ulong query_length= 0;
enum_binlog_format save_binlog_format;
uint new_password_len= (uint) strlen(new_password);
int result=0;
- const CSET_STRING query_save = thd->query_string;
+ const CSET_STRING query_save __attribute__((unused)) = thd->query_string;
DBUG_ENTER("change_password");
DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'",
@@ -2669,16 +2669,18 @@ bool change_password(THD *thd, const char *host, const char *user,
if (check_change_password(thd, host, user, new_password, new_password_len))
DBUG_RETURN(1);
-#ifdef WITH_WSREP
- if (WSREP(thd) && !thd->wsrep_applier)
+ if (mysql_bin_log.is_open() ||
+ (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0)))
{
query_length= sprintf(buff, "SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
- safe_str(user), safe_str(host), new_password);
- thd->set_query_inner(buff, query_length, system_charset_info);
+ safe_str(user), safe_str(host), new_password);
+ }
+ if (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0))
+ {
+ thd->set_query_inner(buff, query_length, system_charset_info);
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, (char*)"user", NULL);
}
-#endif /* WITH_WSREP */
if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user)))
DBUG_RETURN(result != 1);
@@ -2730,34 +2732,27 @@ bool change_password(THD *thd, const char *host, const char *user,
result= 0;
if (mysql_bin_log.is_open())
{
- query_length=
- sprintf(buff,"SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
- safe_str(acl_user->user.str),
- safe_str(acl_user->host.hostname),
- new_password);
+ DBUG_ASSERT(query_length);
thd->clear_error();
result= thd->binlog_query(THD::STMT_QUERY_TYPE, buff, query_length,
FALSE, FALSE, FALSE, 0);
}
end:
close_mysql_tables(thd);
+
#ifdef WITH_WSREP
+error: // this label is used in WSREP_TO_ISOLATION_END
if (WSREP(thd) && !thd->wsrep_applier)
{
WSREP_TO_ISOLATION_END;
- thd->query_string = query_save;
+ thd->set_query_inner(query_save);
thd->wsrep_exec_mode = LOCAL_STATE;
}
#endif /* WITH_WSREP */
thd->restore_stmt_binlog_format(save_binlog_format);
DBUG_RETURN(result);
-
-error:
- WSREP_ERROR("Repliation of SET PASSWORD failed: %s", buff);
- DBUG_RETURN(result);
-
}
int acl_check_set_default_role(THD *thd, const char *host, const char *user)
@@ -2773,10 +2768,11 @@ int acl_set_default_role(THD *thd, const char *host, const char *user,
char user_key[MAX_KEY_LENGTH];
int result= 1;
int error;
+ ulong query_length= 0;
bool clear_role= FALSE;
char buff[512];
enum_binlog_format save_binlog_format;
- const CSET_STRING query_save = thd->query_string;
+ const CSET_STRING query_save __attribute__((unused)) = thd->query_string;
DBUG_ENTER("acl_set_default_role");
DBUG_PRINT("enter",("host: '%s' user: '%s' rolename: '%s'",
@@ -2795,6 +2791,20 @@ int acl_set_default_role(THD *thd, const char *host, const char *user,
if (!strcasecmp(rolename, "NONE"))
clear_role= TRUE;
+ if (mysql_bin_log.is_open() ||
+ (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0)))
+ {
+ query_length=
+ sprintf(buff,"SET DEFAULT ROLE '%-.120s' FOR '%-.120s'@'%-.120s'",
+ safe_str(rolename), safe_str(user), safe_str(host));
+ }
+
+ if (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0))
+ {
+ thd->set_query_inner(buff, query_length, system_charset_info);
+ WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, (char*)"user", NULL);
+ }
+
if ((result= open_grant_tables(thd, tables, TL_WRITE, Table_user)))
DBUG_RETURN(result != 1);
@@ -2871,11 +2881,7 @@ int acl_set_default_role(THD *thd, const char *host, const char *user,
result= 0;
if (mysql_bin_log.is_open())
{
- int query_length=
- sprintf(buff,"SET DEFAULT ROLE '%-.120s' FOR '%-.120s'@'%-.120s'",
- safe_str(acl_user->default_rolename.str),
- safe_str(acl_user->user.str),
- safe_str(acl_user->host.hostname));
+ DBUG_ASSERT(query_length);
thd->clear_error();
result= thd->binlog_query(THD::STMT_QUERY_TYPE, buff, query_length,
FALSE, FALSE, FALSE, 0);
@@ -2884,11 +2890,12 @@ end:
close_mysql_tables(thd);
#ifdef WITH_WSREP
+error: // this label is used in WSREP_TO_ISOLATION_END
if (WSREP(thd) && !thd->wsrep_applier)
{
WSREP_TO_ISOLATION_END;
- thd->query_string = query_save;
+ thd->set_query_inner(query_save);
thd->wsrep_exec_mode = LOCAL_STATE;
}
#endif /* WITH_WSREP */
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 25722a68022..4687a05893c 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4417,7 +4417,7 @@ restart:
flags))
{
error= TRUE;
- goto err;
+ goto error;
}
}
else
@@ -4427,7 +4427,7 @@ restart:
ot_ctx.get_timeout(), flags))
{
error= TRUE;
- goto err;
+ goto error;
}
for (table= *start; table && table != thd->lex->first_not_own_table();
table= table->next_global)
@@ -4485,16 +4485,16 @@ restart:
it may change in future.
*/
if (ot_ctx.recover_from_failed_open())
- goto err;
+ goto error;
/* Re-open temporary tables after close_tables_for_reopen(). */
if (open_temporary_tables(thd, *start))
- goto err;
+ goto error;
error= FALSE;
goto restart;
}
- goto err;
+ goto error;
}
DEBUG_SYNC(thd, "open_tables_after_open_and_process_table");
@@ -4542,11 +4542,11 @@ restart:
close_tables_for_reopen(thd, start,
ot_ctx.start_of_statement_svp());
if (ot_ctx.recover_from_failed_open())
- goto err;
+ goto error;
/* Re-open temporary tables after close_tables_for_reopen(). */
if (open_temporary_tables(thd, *start))
- goto err;
+ goto error;
error= FALSE;
goto restart;
@@ -4556,7 +4556,7 @@ restart:
Something is wrong with the table or its contents, and an error has
been emitted; we must abort.
*/
- goto err;
+ goto error;
}
}
}
@@ -4567,44 +4567,37 @@ restart:
children, attach the children to their parents. At end of statement,
the children are detached. Attaching and detaching are always done,
even under LOCK TABLES.
+
+ And start wsrep TOI if needed.
*/
for (tables= *start; tables; tables= tables->next_global)
{
TABLE *tbl= tables->table;
+ if (!tbl)
+ continue;
+
+ if (WSREP_ON && sqlcom_can_generate_row_events(thd) &&
+ wsrep_replicate_myisam && tables && tbl->file->ht == myisam_hton &&
+ tables->lock_type >= TL_WRITE_ALLOW_WRITE)
+ {
+ WSREP_TO_ISOLATION_BEGIN(NULL, NULL, tables);
+ }
+
/* Schema tables may not have a TABLE object here. */
- if (tbl && tbl->file->ht->db_type == DB_TYPE_MRG_MYISAM)
+ if (tbl->file->ht->db_type == DB_TYPE_MRG_MYISAM)
{
/* MERGE tables need to access parent and child TABLE_LISTs. */
DBUG_ASSERT(tbl->pos_in_table_list == tables);
if (tbl->file->extra(HA_EXTRA_ATTACH_CHILDREN))
{
error= TRUE;
- goto err;
+ goto error;
}
}
}
-#ifdef WITH_WSREP
- if (WSREP_ON &&
- (thd->lex->sql_command== SQLCOM_INSERT ||
- thd->lex->sql_command== SQLCOM_INSERT_SELECT ||
- thd->lex->sql_command== SQLCOM_REPLACE ||
- thd->lex->sql_command== SQLCOM_REPLACE_SELECT ||
- thd->lex->sql_command== SQLCOM_UPDATE ||
- thd->lex->sql_command== SQLCOM_UPDATE_MULTI ||
- thd->lex->sql_command== SQLCOM_LOAD ||
- thd->lex->sql_command== SQLCOM_DELETE) &&
- wsrep_replicate_myisam &&
- (*start) &&
- (*start)->table && (*start)->table->file->ht->db_type == DB_TYPE_MYISAM)
- {
- WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start));
- }
- error:
-#endif
-
-err:
+error:
THD_STAGE_INFO(thd, stage_after_opening_tables);
thd_proc_info(thd, 0);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 57ff2d61cb6..1642319535c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4764,14 +4764,12 @@ end_with_restore_list:
thd->print_aborted_warning(3, "RELEASE");
}
#ifdef WITH_WSREP
- if (WSREP(thd))
+ if (WSREP(thd) && (thd->wsrep_conflict_state != NO_CONFLICT &&
+ thd->wsrep_conflict_state != REPLAYING))
{
- if (thd->wsrep_conflict_state == NO_CONFLICT ||
- thd->wsrep_conflict_state == REPLAYING)
- {
- my_ok(thd);
- }
- } else
+ DBUG_ASSERT(thd->is_error()); // the error is already issued
+ }
+ else
#endif /* WITH_WSREP */
my_ok(thd);
break;
@@ -4810,11 +4808,9 @@ end_with_restore_list:
if (tx_release)
thd->killed= KILL_CONNECTION;
#ifdef WITH_WSREP
- if (WSREP(thd))
+ if (WSREP(thd) && thd->wsrep_conflict_state != NO_CONFLICT)
{
- if (thd->wsrep_conflict_state == NO_CONFLICT) {
- my_ok(thd);
- }
+ DBUG_ASSERT(thd->is_error()); // the error is already issued
}
else
#endif /* WITH_WSREP */
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 577474cd78f..24e61588a06 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -2709,11 +2709,11 @@ main(int argc, char **argv)
return 1;
}
-#ifdef WITH_WSREP
// Replicate MyISAM DDL for this session, cf. lp:1161432
// timezone info unfixable in XtraDB Cluster
- printf("SET GLOBAL wsrep_replicate_myisam= ON;\n");
-#endif /* WITH_WSREP */
+ printf("set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');\n"
+ "prepare set_wsrep_myisam from @prep;\n"
+ "set @toggle=1; execute set_wsrep_myisam using @toggle;\n");
if (argc == 1 && !opt_leap)
{
@@ -2762,10 +2762,8 @@ main(int argc, char **argv)
free_root(&tz_storage, MYF(0));
}
-#ifdef WITH_WSREP
// Reset wsrep_replicate_myisam. lp:1161432
- printf("SET GLOBAL wsrep_replicate_myisam= OFF;\n");
-#endif /* WITH_WSREP */
+ printf("set @toggle=0; execute set_wsrep_myisam using @toggle;\n");
free_defaults(default_argv);
my_end(0);
diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc
index 4fc9ce2bce2..b77cc54ee15 100644
--- a/sql/wsrep_hton.cc
+++ b/sql/wsrep_hton.cc
@@ -157,6 +157,11 @@ static int wsrep_prepare(handlerton *hton, THD *thd, bool all)
!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
(thd->variables.wsrep_on && !wsrep_trans_cache_is_empty(thd)))
{
+ int res= wsrep_run_wsrep_commit(thd, hton, all);
+ if (res == WSREP_TRX_SIZE_EXCEEDED)
+ res= EMSGSIZE;
+ else
+ res= EDEADLK; // for a better error message
DBUG_RETURN (wsrep_run_wsrep_commit(thd, hton, all));
}
DBUG_RETURN(0);
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 938ec243f61..64b7d6c8721 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -37,6 +37,12 @@
#include <slave.h>
wsrep_t *wsrep = NULL;
+/*
+ wsrep_emulate_bin_log is a flag to tell that binlog has not been configured.
+ wsrep needs to get binlog events from transaction cache even when binlog is
+ not enabled, wsrep_emulate_bin_log opens needed code paths to make this
+ possible
+*/
my_bool wsrep_emulate_bin_log = FALSE; // activating parts of binlog interface
#ifdef GTID_SUPPORT
/* Sidno in global_sid_map corresponding to group uuid */
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index 236dfa8884f..ce22dc473fb 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -330,6 +330,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
#define wsrep_deinit(X) do { } while(0)
#define wsrep_recover() do { } while(0)
#define wsrep_slave_threads (1)
+#define wsrep_replicate_myisam (0)
#endif /* WITH_WSREP */
#endif /* WSREP_MYSQLD_H */
diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h
index 9914e98dcdb..0d01d28f01b 100644
--- a/sql/wsrep_thd.h
+++ b/sql/wsrep_thd.h
@@ -31,6 +31,9 @@ void wsrep_create_rollbacker();
int wsrep_abort_thd(void *bf_thd_ptr, void *victim_thd_ptr,
my_bool signal);
+/*
+ PA = Parallel Applying (on the slave side)
+*/
extern void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
extern my_bool wsrep_thd_is_BF(THD *thd, my_bool sync);
extern my_bool wsrep_thd_is_wsrep(void *thd_ptr);
@@ -44,7 +47,7 @@ extern "C" int wsrep_thd_in_locking_session(void *thd_ptr);
#define wsrep_thd_is_BF(T, S) (0)
#define wsrep_abort_thd(X,Y,Z) do { } while(0)
-#define wsrep_create_appliers(T) (0)
+#define wsrep_create_appliers(T) do { } while(0)
#endif
#endif /* WSREP_THD_H */