summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2020-10-05 13:26:28 +1100
committerDaniel Black <daniel@mariadb.org>2020-10-08 07:41:55 +1100
commit874942a0f910731b54eb57aef01c1bef701ab6ba (patch)
tree585f905f3a3658178e668cae8fcc8553e3420b2d
parent00c44fb18ec54682ffd208126e0de6ab172fa50b (diff)
downloadmariadb-git-874942a0f910731b54eb57aef01c1bef701ab6ba.tar.gz
MDEV-4851: (tests) log tables modifiable on log_output!=TABLEbb-10.1-danielblack-MDEV-4851
Test we can ALTER log tables directly when not being written to. This removes the contraint in the rpl_mysql_upgrade.test such that we can run mysql_upgrade --write-binlog all the way through to a replica. We test this in the replication scenario where the mysql.{slow,general}_log tables aren't being written to. Reviewers: Vicențiu Ciorbaru, Anel Husakovic
-rw-r--r--mysql-test/r/log_tables.result8
-rw-r--r--mysql-test/suite/rpl/r/rpl_mysql_upgrade.result54
-rw-r--r--mysql-test/suite/rpl/t/rpl_mysql_upgrade.test34
-rw-r--r--mysql-test/t/log_tables.test20
4 files changed, 101 insertions, 15 deletions
diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result
index ff5055e1ae4..cfecae91733 100644
--- a/mysql-test/r/log_tables.result
+++ b/mysql-test/r/log_tables.result
@@ -377,6 +377,14 @@ slow_log
slow_log_new
drop table slow_log_new, general_log_new;
use test;
+SET GLOBAL LOG_OUTPUT = 'FILE';
+SET GLOBAL slow_query_log = 1;
+SET GLOBAL general_log = 1;
+ALTER TABLE mysql.slow_log ADD COLUMN comment_text TEXT NOT NULL;
+ALTER TABLE mysql.general_log ADD COLUMN comment_text TEXT NOT NULL;
+SET GLOBAL LOG_OUTPUT = 'NONE';
+ALTER TABLE mysql.slow_log DROP COLUMN comment_text;
+ALTER TABLE mysql.general_log DROP COLUMN comment_text;
SET GLOBAL LOG_OUTPUT = 'TABLE';
SET GLOBAL general_log = 0;
FLUSH LOGS;
diff --git a/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result b/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result
index 9e360beba2c..5bc891d90fc 100644
--- a/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result
+++ b/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result
@@ -2,12 +2,54 @@ include/master-slave.inc
[connection master]
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
call mtr.add_suppression("table or database name 'mysqltest-1'");
-DROP DATABASE IF EXISTS `#mysql50#mysqltest-1`;
-CREATE DATABASE `#mysql50#mysqltest-1`;
+CREATE DATABASE `mysqltest-1`;
Master position is not changed
-STOP SLAVE SQL_THREAD;
-include/wait_for_slave_sql_to_stop.inc
-Master position has been changed
+SET @old_general_log_state = @@global.general_log;
+SET @old_slow_log_state = @@global.slow_query_log;
+SET @old_log_output = @@global.log_output;
+SET GLOBAL general_log = 'ON';
+SET GLOBAL slow_query_log = 'ON';
+SET GLOBAL log_output = 'FILE';
+ALTER TABLE mysql.slow_log DROP COLUMN thread_id, DROP COLUMN rows_affected;
DROP DATABASE `mysqltest-1`;
-DROP DATABASE `#mysql50#mysqltest-1`;
+SHOW CREATE TABLE mysql.slow_log;
+Table Create Table
+slow_log CREATE TABLE `slow_log` (
+ `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
+ `user_host` mediumtext NOT NULL,
+ `query_time` time(6) NOT NULL,
+ `lock_time` time(6) NOT NULL,
+ `rows_sent` int(11) NOT NULL,
+ `rows_examined` int(11) NOT NULL,
+ `db` varchar(512) NOT NULL,
+ `last_insert_id` int(11) NOT NULL,
+ `insert_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
+ `sql_text` mediumtext NOT NULL
+) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
+Master position has been changed
+SHOW CREATE TABLE mysql.slow_log;
+Table Create Table
+slow_log CREATE TABLE `slow_log` (
+ `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
+ `user_host` mediumtext NOT NULL,
+ `query_time` time(6) NOT NULL,
+ `lock_time` time(6) NOT NULL,
+ `rows_sent` int(11) NOT NULL,
+ `rows_examined` int(11) NOT NULL,
+ `db` varchar(512) NOT NULL,
+ `last_insert_id` int(11) NOT NULL,
+ `insert_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
+ `sql_text` mediumtext NOT NULL,
+ `thread_id` bigint(21) unsigned NOT NULL,
+ `rows_affected` int(11) NOT NULL
+) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
+SET GLOBAL general_log = 'OFF';
+SET GLOBAL slow_query_log = 'OFF';
+truncate mysql.slow_log;
+truncate mysql.general_log;
+SET GLOBAL general_log = @old_general_log_state;
+SET GLOBAL slow_query_log = @old_slow_log_state;
+SET GLOBAL log_output = @old_log_output;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test
index 1931e2eab2a..f44c883ef4e 100644
--- a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test
+++ b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test
@@ -14,8 +14,7 @@ call mtr.add_suppression("table or database name 'mysqltest-1'");
connection master;
--disable_warnings
-DROP DATABASE IF EXISTS `#mysql50#mysqltest-1`;
-CREATE DATABASE `#mysql50#mysqltest-1`;
+CREATE DATABASE `mysqltest-1`;
--enable_warnings
sync_slave_with_master;
@@ -34,13 +33,25 @@ if ($before_position == $after_position)
echo Master position is not changed;
}
-#Some log events of the mysql_upgrade's will cause errors on slave.
+# Some log events of the mysql_upgrade previously caused errors on slave,
+# however with MDEV-4851 this should be ok, so we test it:
connection slave;
-STOP SLAVE SQL_THREAD;
-source include/wait_for_slave_sql_to_stop.inc;
+SET @old_general_log_state = @@global.general_log;
+SET @old_slow_log_state = @@global.slow_query_log;
+SET @old_log_output = @@global.log_output;
+SET GLOBAL general_log = 'ON';
+SET GLOBAL slow_query_log = 'ON';
+SET GLOBAL log_output = 'FILE';
connection master;
#With '--force' option, mysql_upgrade always executes all sql statements for upgrading.
+ALTER TABLE mysql.slow_log DROP COLUMN thread_id, DROP COLUMN rows_affected;
+DROP DATABASE `mysqltest-1`;
+sync_slave_with_master;
+
+connection slave;
+SHOW CREATE TABLE mysql.slow_log;
+connection master;
--exec $MYSQL_UPGRADE --skip-verbose --write-binlog --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade.log 2>&1
let $datadir= `select @@datadir`;
@@ -55,8 +66,15 @@ if ($before_position != $after_position)
echo Master position has been changed;
}
-DROP DATABASE `mysqltest-1`;
+sync_slave_with_master;
connection slave;
-DROP DATABASE `#mysql50#mysqltest-1`;
---let $rpl_only_running_threads= 1
+SHOW CREATE TABLE mysql.slow_log;
+SET GLOBAL general_log = 'OFF';
+SET GLOBAL slow_query_log = 'OFF';
+truncate mysql.slow_log;
+truncate mysql.general_log;
+SET GLOBAL general_log = @old_general_log_state;
+SET GLOBAL slow_query_log = @old_slow_log_state;
+SET GLOBAL log_output = @old_log_output;
+
--source include/rpl_end.inc
diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test
index f822ec8d758..0196e62f12f 100644
--- a/mysql-test/t/log_tables.test
+++ b/mysql-test/t/log_tables.test
@@ -58,7 +58,7 @@ select * from general_log where argument like '%general_log%';
#
# Check some basic queries interfering with the log tables.
-# In our test we'll use a tbale with verbose comments to the short
+# In our test we'll use a table with verbose comments to the short
# command type names, used in the tables
#
@@ -471,6 +471,24 @@ drop table slow_log_new, general_log_new;
use test;
#
+# Bug#69953 / MDEV-4851
+# Log tables should be modifable on LOG_OUTPUT != TABLE
+#
+#
+
+SET GLOBAL LOG_OUTPUT = 'FILE';
+SET GLOBAL slow_query_log = 1;
+SET GLOBAL general_log = 1;
+
+ALTER TABLE mysql.slow_log ADD COLUMN comment_text TEXT NOT NULL;
+ALTER TABLE mysql.general_log ADD COLUMN comment_text TEXT NOT NULL;
+
+SET GLOBAL LOG_OUTPUT = 'NONE';
+ALTER TABLE mysql.slow_log DROP COLUMN comment_text;
+ALTER TABLE mysql.general_log DROP COLUMN comment_text;
+
+
+#
# Bug#27857 (Log tables supplies the wrong value for generating
# AUTO_INCREMENT numbers)
#