From 912ca4c1534988f19ef92538687a020d1d259f3b Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Sat, 20 Aug 2016 13:42:11 +0200 Subject: [PATCH 01/52] GAL-401: MTR test for the fix. --- mysql-test/suite/galera/r/GAL-401.result | 21 ++++++++++ mysql-test/suite/galera/t/GAL-401.test | 49 ++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 mysql-test/suite/galera/r/GAL-401.result create mode 100644 mysql-test/suite/galera/t/GAL-401.test diff --git a/mysql-test/suite/galera/r/GAL-401.result b/mysql-test/suite/galera/r/GAL-401.result new file mode 100644 index 00000000000..bcf83e7e1ff --- /dev/null +++ b/mysql-test/suite/galera/r/GAL-401.result @@ -0,0 +1,21 @@ +SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; +SET @@global.wsrep_desync = 1; +SET SESSION wsrep_sync_wait=0; +SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; +SHOW STATUS LIKE 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 0 +SET @@global.wsrep_desync = 0; +SET SESSION wsrep_sync_wait=7; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` char(1) DEFAULT NULL, + PRIMARY KEY (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CALL mtr.add_suppression("WSREP: Protocol violation. JOIN message sender (.*) is not in state transfer \\(SYNCED\\). Message ignored."); +SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=false'; diff --git a/mysql-test/suite/galera/t/GAL-401.test b/mysql-test/suite/galera/t/GAL-401.test new file mode 100644 index 00000000000..b7ee36fb1c8 --- /dev/null +++ b/mysql-test/suite/galera/t/GAL-401.test @@ -0,0 +1,49 @@ +# This tests proper desync counter cleanup when DONOR/DESYNC state is cleared. + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# Make node 1 tolerate split-brain +SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; + +# Desync and disconnect node 2 from the PC: +--connection node_2 +SET @@global.wsrep_desync = 1; +SET SESSION wsrep_sync_wait=0; +SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +# Wait until node 2 disappears from the PC: +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +# Modify app state to force node 2 into PRIMARY upon reconnection. +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); + +# Reconnect node 2 to the PC: +--connection node_2 +SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +# Must return 0: +SHOW STATUS LIKE 'wsrep_desync_count'; + +# Resync node_2, should pass: +SET @@global.wsrep_desync = 0; + +SET SESSION wsrep_sync_wait=7; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CALL mtr.add_suppression("WSREP: Protocol violation. JOIN message sender (.*) is not in state transfer \\(SYNCED\\). Message ignored."); + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc +SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=false'; From e757e02417afcaccd8d5c188cad597b9ca7d96d3 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Wed, 22 Mar 2017 10:04:57 +0530 Subject: [PATCH 02/52] Galera MTR Tests: Copy over some MTR tests from PXC Signed-off-by: Sachin Setiya --- .../galera/galera_2nodes_as_master_slave.cnf | 83 +++++++ ...lera_2nodes_as_master_with_repl_filter.cnf | 87 +++++++ mysql-test/suite/galera/r/ev51914.result | 162 +++++++++++++ mysql-test/suite/galera/r/galera_admin.result | 43 ++++ .../galera/r/galera_desync_overlapped.result | 45 ++++ .../r/galera_restart_on_unknown_option.result | 40 ++++ .../galera/r/galera_toi_ddl_fk_update.result | 23 ++ .../galera/r/galera_toi_ddl_online.result | 27 +++ .../galera/r/galera_toi_drop_database.result | 22 ++ .../suite/galera/r/galera_toi_truncate.result | 17 ++ ...alera_wsrep_provider_options_syntax.result | 5 + mysql-test/suite/galera/r/lp1376747-2.result | 19 ++ mysql-test/suite/galera/r/lp1376747-3.result | 21 ++ mysql-test/suite/galera/r/lp1376747-4.result | 36 +++ mysql-test/suite/galera/r/lp1376747.result | 19 ++ mysql-test/suite/galera/r/pxc-421.result | 35 +++ mysql-test/suite/galera/t/ev51914.test | 214 ++++++++++++++++++ mysql-test/suite/galera/t/galera_admin.test | 86 +++++++ .../galera/t/galera_desync_overlapped.test | 59 +++++ .../suite/galera/t/galera_flush_local.opt | 2 +- .../t/galera_restart_on_unknown_option.test | 150 ++++++++++++ .../galera/t/galera_toi_ddl_fk_update.test | 49 ++++ .../suite/galera/t/galera_toi_ddl_online.test | 53 +++++ .../galera/t/galera_toi_drop_database.test | 54 +++++ .../suite/galera/t/galera_toi_truncate.test | 77 +++++++ .../galera_wsrep_provider_options_syntax.test | 20 ++ mysql-test/suite/galera/t/lp1376747-2.test | 22 ++ mysql-test/suite/galera/t/lp1376747-3.test | 28 +++ mysql-test/suite/galera/t/lp1376747-4.test | 53 +++++ mysql-test/suite/galera/t/lp1376747.test | 24 ++ mysql-test/suite/galera/t/pxc-421.test | 60 +++++ 31 files changed, 1634 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf create mode 100644 mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf create mode 100644 mysql-test/suite/galera/r/ev51914.result create mode 100644 mysql-test/suite/galera/r/galera_admin.result create mode 100644 mysql-test/suite/galera/r/galera_desync_overlapped.result create mode 100644 mysql-test/suite/galera/r/galera_restart_on_unknown_option.result create mode 100644 mysql-test/suite/galera/r/galera_toi_ddl_fk_update.result create mode 100644 mysql-test/suite/galera/r/galera_toi_ddl_online.result create mode 100644 mysql-test/suite/galera/r/galera_toi_drop_database.result create mode 100644 mysql-test/suite/galera/r/galera_toi_truncate.result create mode 100644 mysql-test/suite/galera/r/galera_wsrep_provider_options_syntax.result create mode 100644 mysql-test/suite/galera/r/lp1376747-2.result create mode 100644 mysql-test/suite/galera/r/lp1376747-3.result create mode 100644 mysql-test/suite/galera/r/lp1376747-4.result create mode 100644 mysql-test/suite/galera/r/lp1376747.result create mode 100644 mysql-test/suite/galera/r/pxc-421.result create mode 100644 mysql-test/suite/galera/t/ev51914.test create mode 100644 mysql-test/suite/galera/t/galera_admin.test create mode 100644 mysql-test/suite/galera/t/galera_desync_overlapped.test create mode 100644 mysql-test/suite/galera/t/galera_restart_on_unknown_option.test create mode 100644 mysql-test/suite/galera/t/galera_toi_ddl_fk_update.test create mode 100644 mysql-test/suite/galera/t/galera_toi_ddl_online.test create mode 100644 mysql-test/suite/galera/t/galera_toi_drop_database.test create mode 100644 mysql-test/suite/galera/t/galera_toi_truncate.test create mode 100644 mysql-test/suite/galera/t/galera_wsrep_provider_options_syntax.test create mode 100644 mysql-test/suite/galera/t/lp1376747-2.test create mode 100644 mysql-test/suite/galera/t/lp1376747-3.test create mode 100644 mysql-test/suite/galera/t/lp1376747-4.test create mode 100644 mysql-test/suite/galera/t/lp1376747.test create mode 100644 mysql-test/suite/galera/t/pxc-421.test diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf new file mode 100644 index 00000000000..716a790fea6 --- /dev/null +++ b/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf @@ -0,0 +1,83 @@ + +# +# Let's understand the topology. +# * Independent Master with server-id = 1 +# * Galera cluster with 2 nodes: node#1 and node#2 with server-id = 2, 3 +# node#1 act as slave to Independent Master with server-id = 1 +# * Independent Slave with server-id = 4 replicating from galera node#2 +# + +# Use default setting for mysqld processes +!include include/default_mysqld.cnf + +[mysqld] +log-slave-updates +log-bin=mysqld-bin +binlog-format=row +gtid-mode=on +enforce-gtid-consistency=true + +[mysqld.1] +server-id=1 + +[mysqld.2] +server-id=2 + +wsrep_provider=@ENV.WSREP_PROVIDER +wsrep_cluster_address='gcomm://' +wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts=1;' + +# enforce read-committed characteristics across the cluster +wsrep_causal_reads=ON +wsrep_sync_wait = 7 + +wsrep_node_address=127.0.0.1 +wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port + +# Required for Galera +innodb_autoinc_lock_mode=2 + +innodb_flush_log_at_trx_commit=2 + +[mysqld.3] +server-id=3 + +wsrep_provider=@ENV.WSREP_PROVIDER +wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;' + +# enforce read-committed characteristics across the cluster +wsrep_causal_reads=ON +wsrep_sync_wait = 7 + +wsrep_node_address=127.0.0.1 +wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port + +# Required for Galera +innodb_autoinc_lock_mode=2 + +innodb_flush_log_at_trx_commit=2 + +[mysqld.4] +server-id=4 + +[ENV] +NODE_MYPORT_1= @mysqld.1.port +NODE_MYSOCK_1= @mysqld.1.socket + +NODE_MYPORT_2= @mysqld.2.port +NODE_MYSOCK_2= @mysqld.2.socket + +NODE_MYPORT_3= @mysqld.3.port +NODE_MYSOCK_3= @mysqld.3.socket + +NODE_MYPORT_4= @mysqld.4.port +NODE_MYSOCK_4= @mysqld.4.socket + +NODE_GALERAPORT_2= @mysqld.2.#galera_port +NODE_GALERAPORT_3= @mysqld.3.#galera_port + +NODE_SSTPORT_2= @mysqld.2.#sst_port +NODE_SSTPORT_3= @mysqld.3.#sst_port diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf new file mode 100644 index 00000000000..5f0af2e58e5 --- /dev/null +++ b/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf @@ -0,0 +1,87 @@ +# +# This .cnf file creates a setup with a 2-node Galera cluster and one stand-alone MySQL server, to be used as a slave +# + +# Use default setting for mysqld processes +!include include/default_mysqld.cnf + +[mysqld] +default-storage-engine=InnoDB + +[mysqld.1] +server-id=1 +binlog-format=row +log-bin=mysqld-bin +log_slave_updates +gtid-mode=on +enforce-gtid-consistency=true +event-scheduler=1 + +wsrep_provider=@ENV.WSREP_PROVIDER +wsrep_cluster_address='gcomm://' +wsrep_provider_options='base_port=@mysqld.1.#galera_port' + +# enforce read-committed characteristics across the cluster +wsrep_causal_reads=ON +wsrep_sync_wait = 7 + +wsrep_node_address=127.0.0.1 +wsrep_sst_receive_address=127.0.0.2:@mysqld.1.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port + +# Required for Galera +innodb_autoinc_lock_mode=2 + +innodb_flush_log_at_trx_commit=2 + +[mysqld.2] +server-id=2 +binlog-format=row +log-bin=mysqld-bin +log_slave_updates +gtid-mode=on +enforce-gtid-consistency=true +event-scheduler=1 + +wsrep_provider=@ENV.WSREP_PROVIDER +wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.2.#galera_port' + +# enforce read-committed characteristics across the cluster +wsrep_causal_reads=ON +wsrep_sync_wait = 7 + +wsrep_node_address=127.0.0.1 +wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port + +# Required for Galera +innodb_autoinc_lock_mode=2 + +innodb_flush_log_at_trx_commit=2 + +[mysqld.3] +server-id=3 +replicate-ignore-db=test +replicate-wild-ignore-table=test.% +log-bin=mysqld-bin +log_slave_updates +gtid-mode=on +enforce-gtid-consistency=true +event-scheduler=1 + +[ENV] +NODE_MYPORT_1= @mysqld.1.port +NODE_MYSOCK_1= @mysqld.1.socket + +NODE_MYPORT_2= @mysqld.2.port +NODE_MYSOCK_2= @mysqld.2.socket + +NODE_MYPORT_3= @mysqld.3.port +NODE_MYSOCK_3= @mysqld.3.socket + +NODE_GALERAPORT_1= @mysqld.1.#galera_port +NODE_GALERAPORT_2= @mysqld.2.#galera_port + +NODE_SSTPORT_1= @mysqld.1.#sst_port +NODE_SSTPORT_2= @mysqld.2.#sst_port diff --git a/mysql-test/suite/galera/r/ev51914.result b/mysql-test/suite/galera/r/ev51914.result new file mode 100644 index 00000000000..4b9f7ace0da --- /dev/null +++ b/mysql-test/suite/galera/r/ev51914.result @@ -0,0 +1,162 @@ +SAVEPOINT in a stored function should be forbidden +CREATE FUNCTION f1 () RETURNS INT BEGIN +SAVEPOINT s; +RETURN 1; +END| +SELECT f1(); +f1() +1 +DROP FUNCTION f1; +ROLLBACK TO SAVEPOINT in a stored function should be forbidden +CREATE FUNCTION f2 () RETURNS INT BEGIN +ROLLBACK TO SAVEPOINT s; +RETURN 1; +END| +BEGIN; +SAVEPOINT s; +SELECT f2(); +ERROR 42000: SAVEPOINT s does not exist +COMMIT; +DROP FUNCTION f2; +BEGIN; +SAVEPOINT S; +ROLLBACK TO SAVEPOINT S; +COMMIT; +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (a INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 values (110), (111), (112), (113), (114); +Direct SAVEPOINT in a trigger should be forbidden +CREATE TRIGGER i1_t1 BEFORE INSERT ON t1 FOR EACH ROW SAVEPOINT s; +INSERT INTO t1 VALUES (1); +DROP TRIGGER i1_t1; +CREATE TRIGGER i2_t1 AFTER INSERT ON t1 FOR EACH ROW SAVEPOINT s; +INSERT INTO t1 VALUES (2); +DROP TRIGGER i2_t1; +INSERT INTO t1 VALUES (3); +CREATE TRIGGER u1_t1 BEFORE UPDATE ON t1 FOR EACH ROW SAVEPOINT s; +UPDATE t1 SET a=4 WHERE a=3; +DROP TRIGGER u1_t1; +CREATE TRIGGER u2_t1 AFTER UPDATE ON t1 FOR EACH ROW SAVEPOINT s; +UPDATE t1 SET a=4 WHERE a=3; +DROP TRIGGER u2_t1; +CREATE TRIGGER d1_t1 BEFORE DELETE ON t1 FOR EACH ROW SAVEPOINT s; +DELETE FROM t1; +DROP TRIGGER d1_t1; +CREATE TRIGGER d1_t1 AFTER DELETE ON t1 FOR EACH ROW SAVEPOINT s; +DELETE FROM t1; +DROP TRIGGER d1_t1; +SAVEPOINT in a compound statement in a trigger should be forbidden +CREATE TRIGGER i3_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN +SAVEPOINT s; +END| +INSERT INTO t1 VALUES (5); +DROP TRIGGER i3_t1; +SAVEPOINT in a PS call in a trigger should be forbidden +CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN +PREPARE set_savepoint FROM "SAVEPOINT s"; +EXECUTE set_savepoint; +DEALLOCATE PREPARE set_savepoint; +END| +ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger +SAVEPOINT in SP called from a trigger should be forbidden +CREATE PROCEDURE p1() BEGIN +SAVEPOINT s; +END| +CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1; +INSERT INTO t1 VALUES (6); +DROP TRIGGER i5_t1; +SAVEPOINT in a SP called from a PS called from a trigger be forbidden +PREPARE call_p1 FROM "CALL p1"; +CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW EXECUTE call_p1; +ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger +SAVEPOINT in a function called from a trigger should be forbidden +CREATE FUNCTION f1 () RETURNS INT BEGIN +SAVEPOINT s; +RETURN 1; +END| +CREATE TRIGGER i7_t1 BEFORE INSERT ON t1 FOR EACH ROW SET @foo = f1(); +INSERT INTO t1 VALUES (7); +DROP TRIGGER i7_t1; +SAVEPOINT in a SP called from a SP called from a trigger should be forbidden +CREATE PROCEDURE p2() BEGIN +CALL p1(); +END| +CREATE TRIGGER i8_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p2; +INSERT INTO t1 VALUES (8); +DROP TRIGGER i8_t1; +SAVEPOINT in a SP called from a trigger called from a SP should be forbidden +CREATE TRIGGER i9_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1; +CREATE PROCEDURE p3() BEGIN +INSERT INTO t1 VALUES (9); +END| +CALL p3(); +DROP TRIGGER i9_t1; +ROLLBACK TO SAVEPOINT in trigger as a trivial statement should be forbidden +CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW ROLLBACK TO SAVEPOINT s; +BEGIN; +SAVEPOINT s; +INSERT INTO t1 VALUES (5); +ERROR 42000: SAVEPOINT s does not exist +COMMIT; +DROP TRIGGER i4_t1; +ROLLBACK TO SAVEPOINT in a trigger in a SP call should be forbidden +CREATE PROCEDURE p4() BEGIN +ROLLBACK TO SAVEPOINT s; +END| +CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p4; +BEGIN; +SAVEPOINT s; +INSERT INTO t1 VALUES (6); +ERROR 42000: SAVEPOINT s does not exist +COMMIT; +DROP TRIGGER i5_t1; +SAVEPOINT in a SP next to a trigger should work +CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a = NEW.a + 1; +CREATE PROCEDURE p5() BEGIN +SAVEPOINT s; +INSERT INTO t1 VALUES (10); +ROLLBACK TO SAVEPOINT s; +END| +BEGIN; +CALL p5(); +COMMIT; +DROP TRIGGER i6_t1; +create trigger t1 before insert on t1 for each row +begin +insert into t2 values (NULL); +end| +INSERT INTO t1 VALUES (201), (202), (203); +SELECT * FROM t1; +a +5 +6 +7 +8 +9 +201 +202 +203 +SELECT COUNT(*) FROM t2; +COUNT(*) +3 +SELECT * FROM t1; +a +5 +6 +7 +8 +9 +201 +202 +203 +SELECT COUNT(*) FROM t2; +COUNT(*) +3 +DEALLOCATE PREPARE call_p1; +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +DROP PROCEDURE p5; +DROP FUNCTION f1; diff --git a/mysql-test/suite/galera/r/galera_admin.result b/mysql-test/suite/galera/r/galera_admin.result new file mode 100644 index 00000000000..e58b0a5e310 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_admin.result @@ -0,0 +1,43 @@ +DROP TABLE IF EXISTS t1, t2; +DROP TABLE IF EXISTS x1, x2; +CREATE TABLE t1 (f1 INTEGER); +CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); +SET GLOBAL wsrep_replicate_myisam = TRUE; +CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4; +INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +# ANALYZE test +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +# OPTIMIZE test +OPTIMIZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +# REPAIR test +REPAIR TABLE x1, x2; +Table Op Msg_type Msg_text +test.x1 repair status OK +test.x2 repair status OK +SELECT COUNT(*) = 10 FROM t1; +COUNT(*) = 10 +1 +SELECT COUNT(*) = 10 FROM x1; +COUNT(*) = 10 +1 +SELECT COUNT(*) = 10000 FROM t2; +COUNT(*) = 10000 +1 +SELECT COUNT(*) = 10 FROM x2; +COUNT(*) = 10 +1 +DROP TABLE t1, t2; +DROP TABLE x1, x2; +SET GLOBAL wsrep_replicate_myisam = FALSE; diff --git a/mysql-test/suite/galera/r/galera_desync_overlapped.result b/mysql-test/suite/galera/r/galera_desync_overlapped.result new file mode 100644 index 00000000000..a1e7d59a661 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_desync_overlapped.result @@ -0,0 +1,45 @@ +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB; +CREATE TABLE t2 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB; +SET GLOBAL wsrep_desync = 1; +show status like 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 1 +SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter1 WAIT_FOR alter2'; +INSERT INTO t1 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3; +SET GLOBAL wsrep_desync = 1; +Warnings: +Warning 1231 'wsrep_desync' is already ON. +show status like 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 1 +SET DEBUG_SYNC='now WAIT_FOR alter1'; +SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter2'; +INSERT INTO t2 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3; +SET DEBUG_SYNC='RESET'; +SET GLOBAL wsrep_desync = 0; +show status like 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 0 +SET GLOBAL wsrep_desync = 0; +Warnings: +Warning 1231 'wsrep_desync' is already OFF. +show status like 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 0 +show status like 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 0 +SET GLOBAL wsrep_desync = 0; +Warnings: +Warning 1231 'wsrep_desync' is already OFF. +SELECT COUNT(*) FROM t1; +COUNT(*) +1000 +SELECT COUNT(*) FROM t2; +COUNT(*) +1000 +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/r/galera_restart_on_unknown_option.result b/mysql-test/suite/galera/r/galera_restart_on_unknown_option.result new file mode 100644 index 00000000000..a21b1edf3e7 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_restart_on_unknown_option.result @@ -0,0 +1,40 @@ +CALL mtr.add_suppression("Aborting"); +CALL mtr.add_suppression("unknown option '--galera-unknown-option'"); +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a'); +SELECT * FROM t1; +f1 f2 +1 a +2 a +3 a +Shutting down server ... +UPDATE t1 SET f2 = 'b' WHERE f1 > 1; +UPDATE t1 SET f2 = 'c' WHERE f1 > 2; +SELECT * FROM t1; +f1 f2 +1 a +2 b +3 c +Starting server ... +Starting server ... +SELECT * FROM t1; +f1 f2 +1 a +2 b +3 c +Shutting down server ... +UPDATE t1 SET f2 = 'd' WHERE f1 > 1; +UPDATE t1 SET f2 = 'd' WHERE f1 > 2; +SELECT * FROM t1; +f1 f2 +1 a +2 d +3 d +Starting server ... +Starting server ... +SELECT * FROM t1; +f1 f2 +1 a +2 d +3 d +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_fk_update.result b/mysql-test/suite/galera/r/galera_toi_ddl_fk_update.result new file mode 100644 index 00000000000..8366cfd27c8 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_toi_ddl_fk_update.result @@ -0,0 +1,23 @@ +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +CREATE TABLE parent ( +id INT PRIMARY KEY, +KEY (id) +) ENGINE=InnoDB; +CREATE TABLE child ( +id INT PRIMARY KEY AUTO_INCREMENT, +parent_id INT +) ENGINE=InnoDB; +INSERT INTO parent VALUES (1); +INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; +ALTER TABLE child ADD FOREIGN KEY (parent_id) REFERENCES parent(id) ON UPDATE CASCADE;; +UPDATE parent SET id = 2 WHERE id = 1;; +SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2; +COUNT(*) = 10000 +1 +SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2; +COUNT(*) = 10000 +1 +DROP TABLE child; +DROP TABLE parent; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_online.result b/mysql-test/suite/galera/r/galera_toi_ddl_online.result new file mode 100644 index 00000000000..488b72ab843 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_toi_ddl_online.result @@ -0,0 +1,27 @@ +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; +CREATE INDEX i1 ON t1 (f2);; +ALTER TABLE t1 ADD COLUMN f3 INTEGER;; +SELECT COUNT(*) = 200000 FROM t1; +COUNT(*) = 200000 +1 +SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +COUNT(*) = 3 +1 +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +COUNT(*) = 2 +1 +SELECT COUNT(*) = 200000 FROM t1; +COUNT(*) = 200000 +1 +SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +COUNT(*) = 3 +1 +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +COUNT(*) = 2 +1 +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/r/galera_toi_drop_database.result b/mysql-test/suite/galera/r/galera_toi_drop_database.result new file mode 100644 index 00000000000..d4f98c38847 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_toi_drop_database.result @@ -0,0 +1,22 @@ +CREATE DATABASE database1; +USE database1; +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; +USE database1; +INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; +DROP DATABASE database1;; +ERROR 42S02: Table 'database1.t1' doesn't exist +ERROR 42S02: Table 'database1.t2' doesn't exist +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1'; +COUNT(*) = 0 +1 +USE database1; +ERROR 42000: Unknown database 'database1' +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1'; +COUNT(*) = 0 +1 +USE database1; +ERROR 42000: Unknown database 'database1' diff --git a/mysql-test/suite/galera/r/galera_toi_truncate.result b/mysql-test/suite/galera/r/galera_toi_truncate.result new file mode 100644 index 00000000000..98bc9f4850b --- /dev/null +++ b/mysql-test/suite/galera/r/galera_toi_truncate.result @@ -0,0 +1,17 @@ +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;; +TRUNCATE TABLE t1;; +SELECT COUNT(*) = 1000000 FROM t1; +COUNT(*) = 1000000 +1 +DROP TABLE t1; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;; +TRUNCATE TABLE t1;; +SELECT COUNT(*) = 1000000 FROM t1; +COUNT(*) = 1000000 +1 +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/r/galera_wsrep_provider_options_syntax.result b/mysql-test/suite/galera/r/galera_wsrep_provider_options_syntax.result new file mode 100644 index 00000000000..f19dc40205b --- /dev/null +++ b/mysql-test/suite/galera/r/galera_wsrep_provider_options_syntax.result @@ -0,0 +1,5 @@ +call mtr.add_suppression("WSREP\: Unknown parameter 'gmcasts\.segment'"); +call mtr.add_suppression("WSREP\: Set options returned 7"); +SET GLOBAL wsrep_provider_options="gmcasts.segment=1"; +ERROR HY000: Incorrect arguments to SET +Unhandled exceptions: 0 diff --git a/mysql-test/suite/galera/r/lp1376747-2.result b/mysql-test/suite/galera/r/lp1376747-2.result new file mode 100644 index 00000000000..3b8aee61ed2 --- /dev/null +++ b/mysql-test/suite/galera/r/lp1376747-2.result @@ -0,0 +1,19 @@ +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +FLUSH TABLES t1 FOR EXPORT; +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +INSERT INTO t1 VALUES (2,3); +UNLOCK TABLES; +### t1 should have column f2 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from t1; +id f2 +1 NULL +2 3 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/lp1376747-3.result b/mysql-test/suite/galera/r/lp1376747-3.result new file mode 100644 index 00000000000..fc982c94244 --- /dev/null +++ b/mysql-test/suite/galera/r/lp1376747-3.result @@ -0,0 +1,21 @@ +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +FLUSH TABLE WITH READ LOCK; +### This shouldn't block. +FLUSH TABLES t1 FOR EXPORT; +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +UNLOCK TABLES; +### t1 should have column f2 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (2,3); +SELECT * from t1; +id f2 +1 NULL +2 3 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/lp1376747-4.result b/mysql-test/suite/galera/r/lp1376747-4.result new file mode 100644 index 00000000000..b0ae2b7fc92 --- /dev/null +++ b/mysql-test/suite/galera/r/lp1376747-4.result @@ -0,0 +1,36 @@ +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET session wsrep_sync_wait=0; +SET session wsrep_causal_reads=OFF; +FLUSH TABLE WITH READ LOCK; +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +INSERT INTO t1 VALUES (2,3); +SET session wsrep_sync_wait=0; +SET session wsrep_causal_reads=OFF; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +FLUSH TABLES t1 WITH READ LOCK;; +UNLOCK TABLES; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +UNLOCK TABLES; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from t1; +id f2 +1 NULL +2 3 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/lp1376747.result b/mysql-test/suite/galera/r/lp1376747.result new file mode 100644 index 00000000000..4617d5952bb --- /dev/null +++ b/mysql-test/suite/galera/r/lp1376747.result @@ -0,0 +1,19 @@ +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +FLUSH TABLES t1 WITH READ LOCK; +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +INSERT INTO t1 VALUES (2,3); +UNLOCK TABLES; +### t1 should have column f2 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from t1; +id f2 +1 NULL +2 3 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/pxc-421.result b/mysql-test/suite/galera/r/pxc-421.result new file mode 100644 index 00000000000..1822201f338 --- /dev/null +++ b/mysql-test/suite/galera/r/pxc-421.result @@ -0,0 +1,35 @@ +set GLOBAL wsrep_slave_threads=26; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 (f1) SELECT * from t1 as x1; +set GLOBAL wsrep_slave_threads=16; +SET GLOBAL wsrep_provider='none'; +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +set GLOBAL wsrep_slave_threads=5; +SELECT COUNT(*) = 5 FROM t1; +COUNT(*) = 5 +1 +set GLOBAL wsrep_slave_threads=12; +SELECT COUNT(*) = 4 FROM t1; +COUNT(*) = 4 +1 +INSERT INTO t1 VALUES (100), (101), (102); +set GLOBAL wsrep_slave_threads=5; +INSERT INTO t1 (f1) SELECT * from t1 as x1; +show global variables like 'wsrep_slave_threads'; +Variable_name Value +wsrep_slave_threads 5 +SET GLOBAL wsrep_slave_threads = 1; +SELECT COUNT(*) FROM t1; +COUNT(*) +16 +SELECT COUNT(*) FROM t1; +COUNT(*) +15 +show global variables like 'wsrep_slave_threads'; +Variable_name Value +wsrep_slave_threads 12 +SET GLOBAL wsrep_slave_threads = 1; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/ev51914.test b/mysql-test/suite/galera/t/ev51914.test new file mode 100644 index 00000000000..e5edacabe89 --- /dev/null +++ b/mysql-test/suite/galera/t/ev51914.test @@ -0,0 +1,214 @@ +# Disable SAVEPOINT and ROLLBACK TO SAVEPOINT in SP, SF, TR. + +--source include/galera_cluster.inc +--source include/have_innodb.inc + + +--connection node_1 +--echo SAVEPOINT in a stored function should be forbidden +--delimiter | +CREATE FUNCTION f1 () RETURNS INT BEGIN + SAVEPOINT s; + RETURN 1; +END| +--delimiter ; + +SELECT f1(); + +DROP FUNCTION f1; + +--echo ROLLBACK TO SAVEPOINT in a stored function should be forbidden +--delimiter | +CREATE FUNCTION f2 () RETURNS INT BEGIN + ROLLBACK TO SAVEPOINT s; + RETURN 1; +END| +--delimiter ; + +BEGIN; +SAVEPOINT s; +--error ER_SP_DOES_NOT_EXIST +SELECT f2(); +COMMIT; + +DROP FUNCTION f2; + +BEGIN; +SAVEPOINT S; +ROLLBACK TO SAVEPOINT S; +COMMIT; + + +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (a INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 values (110), (111), (112), (113), (114); + +--echo Direct SAVEPOINT in a trigger should be forbidden +--connection node_2 +CREATE TRIGGER i1_t1 BEFORE INSERT ON t1 FOR EACH ROW SAVEPOINT s; + +--connection node_1 +INSERT INTO t1 VALUES (1); +DROP TRIGGER i1_t1; + +CREATE TRIGGER i2_t1 AFTER INSERT ON t1 FOR EACH ROW SAVEPOINT s; +INSERT INTO t1 VALUES (2); +DROP TRIGGER i2_t1; + +INSERT INTO t1 VALUES (3); +CREATE TRIGGER u1_t1 BEFORE UPDATE ON t1 FOR EACH ROW SAVEPOINT s; +UPDATE t1 SET a=4 WHERE a=3; +DROP TRIGGER u1_t1; + +CREATE TRIGGER u2_t1 AFTER UPDATE ON t1 FOR EACH ROW SAVEPOINT s; +UPDATE t1 SET a=4 WHERE a=3; +DROP TRIGGER u2_t1; + +CREATE TRIGGER d1_t1 BEFORE DELETE ON t1 FOR EACH ROW SAVEPOINT s; +DELETE FROM t1; +DROP TRIGGER d1_t1; + +CREATE TRIGGER d1_t1 AFTER DELETE ON t1 FOR EACH ROW SAVEPOINT s; +DELETE FROM t1; +DROP TRIGGER d1_t1; + +--echo SAVEPOINT in a compound statement in a trigger should be forbidden +--delimiter | +CREATE TRIGGER i3_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN + SAVEPOINT s; +END| +--delimiter ; +INSERT INTO t1 VALUES (5); +DROP TRIGGER i3_t1; + +--echo SAVEPOINT in a PS call in a trigger should be forbidden +# echo handled by SAVEPOINT forbidden in PS +--delimiter | +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN + PREPARE set_savepoint FROM "SAVEPOINT s"; + EXECUTE set_savepoint; + DEALLOCATE PREPARE set_savepoint; +END| +--delimiter ; + +--connection node_2 +--echo SAVEPOINT in SP called from a trigger should be forbidden +--delimiter | +CREATE PROCEDURE p1() BEGIN + SAVEPOINT s; +END| +--delimiter ; +--connection node_1 +CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1; +INSERT INTO t1 VALUES (6); +DROP TRIGGER i5_t1; + +--echo SAVEPOINT in a SP called from a PS called from a trigger be forbidden +# echo handled by SAVEPOINT forbidden in PS +PREPARE call_p1 FROM "CALL p1"; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW EXECUTE call_p1; + +--echo SAVEPOINT in a function called from a trigger should be forbidden +--delimiter | +CREATE FUNCTION f1 () RETURNS INT BEGIN + SAVEPOINT s; + RETURN 1; +END| +--delimiter ; +CREATE TRIGGER i7_t1 BEFORE INSERT ON t1 FOR EACH ROW SET @foo = f1(); +INSERT INTO t1 VALUES (7); +DROP TRIGGER i7_t1; + +--echo SAVEPOINT in a SP called from a SP called from a trigger should be forbidden +--delimiter | +CREATE PROCEDURE p2() BEGIN + CALL p1(); +END| +--delimiter ; +CREATE TRIGGER i8_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p2; +INSERT INTO t1 VALUES (8); +DROP TRIGGER i8_t1; + +--echo SAVEPOINT in a SP called from a trigger called from a SP should be forbidden +CREATE TRIGGER i9_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1; +--delimiter | +CREATE PROCEDURE p3() BEGIN + INSERT INTO t1 VALUES (9); +END| +--delimiter ; +CALL p3(); +DROP TRIGGER i9_t1; + +--echo ROLLBACK TO SAVEPOINT in trigger as a trivial statement should be forbidden +# Trigger activation creates a new savepoint level, making the earlier levels +# inaccessible. Thus forbidding SAVEPOINT should be enough as then there is +# no valid savepoint to pass to ROLLBACK TO SAVEPOINT, but we forbid it once +# more just in case. +CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW ROLLBACK TO SAVEPOINT s; +BEGIN; +SAVEPOINT s; +--error ER_SP_DOES_NOT_EXIST +INSERT INTO t1 VALUES (5); +COMMIT; +DROP TRIGGER i4_t1; + +--echo ROLLBACK TO SAVEPOINT in a trigger in a SP call should be forbidden +--delimiter | +CREATE PROCEDURE p4() BEGIN + ROLLBACK TO SAVEPOINT s; +END| +--delimiter ; +CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p4; +BEGIN; +SAVEPOINT s; +--error ER_SP_DOES_NOT_EXIST +INSERT INTO t1 VALUES (6); +COMMIT; +DROP TRIGGER i5_t1; + +--echo SAVEPOINT in a SP next to a trigger should work +CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a = NEW.a + 1; +--delimiter | +CREATE PROCEDURE p5() BEGIN + SAVEPOINT s; + INSERT INTO t1 VALUES (10); + ROLLBACK TO SAVEPOINT s; +END| +--delimiter ; +BEGIN; +CALL p5(); +COMMIT; +DROP TRIGGER i6_t1; + +--connection node_2 +delimiter |; +create trigger t1 before insert on t1 for each row +begin + insert into t2 values (NULL); +end| +delimiter ;| + +--connection node_1 +INSERT INTO t1 VALUES (201), (202), (203); + +--connection node_1 +SELECT * FROM t1; +SELECT COUNT(*) FROM t2; + +--connection node_2 +SELECT * FROM t1; +SELECT COUNT(*) FROM t2; + +--connection node_1 +DEALLOCATE PREPARE call_p1; + +--connection node_2 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +DROP PROCEDURE p5; +DROP FUNCTION f1; diff --git a/mysql-test/suite/galera/t/galera_admin.test b/mysql-test/suite/galera/t/galera_admin.test new file mode 100644 index 00000000000..d62c454bdfa --- /dev/null +++ b/mysql-test/suite/galera/t/galera_admin.test @@ -0,0 +1,86 @@ +# +# Test that various admin commands from sql_admin.cc +# Currently, REPAIR, OPTIMIZE and ANALYZE are tested. +# Jira: PXC-390 +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP TABLE IF EXISTS x1, x2; +--enable_warnings + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER); +CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); +SET GLOBAL wsrep_replicate_myisam = TRUE; +CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4; +INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); + +# Wait until all the data from t2 has been replicated +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 10 FROM x1; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 10 FROM x2; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 10 FROM t1; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 10000 FROM t2; +--source include/wait_condition.inc + + +--echo # ANALYZE test +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--connection node_1 +ANALYZE TABLE t1, t2; + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed' +--source include/wait_condition.inc + + + +--echo # OPTIMIZE test +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--connection node_1 +OPTIMIZE TABLE t1, t2; + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed' +--source include/wait_condition.inc + + + +--echo # REPAIR test +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--connection node_1 +REPAIR TABLE x1, x2; + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed' +--source include/wait_condition.inc + + + +--connection node_2 +SELECT COUNT(*) = 10 FROM t1; +SELECT COUNT(*) = 10 FROM x1; +SELECT COUNT(*) = 10000 FROM t2; +SELECT COUNT(*) = 10 FROM x2; + +--connection node_1 +DROP TABLE t1, t2; +DROP TABLE x1, x2; +SET GLOBAL wsrep_replicate_myisam = FALSE; diff --git a/mysql-test/suite/galera/t/galera_desync_overlapped.test b/mysql-test/suite/galera/t/galera_desync_overlapped.test new file mode 100644 index 00000000000..8b78e8cdeb7 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_desync_overlapped.test @@ -0,0 +1,59 @@ +# +# Test for overlapped transactions under manual desync. +# +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_1 + +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t1 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB; +CREATE TABLE t2 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB; + +SET GLOBAL wsrep_desync = 1; +show status like 'wsrep_desync_count'; +SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter1 WAIT_FOR alter2'; +send INSERT INTO t1 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3; + +--connection node_1a + +SET GLOBAL wsrep_desync = 1; +show status like 'wsrep_desync_count'; +SET DEBUG_SYNC='now WAIT_FOR alter1'; +SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter2'; +send INSERT INTO t2 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3; + +--connection node_1 +reap; + +--connection node_1a +reap; + +--connection node_1 + +SET DEBUG_SYNC='RESET'; + +SET GLOBAL wsrep_desync = 0; +show status like 'wsrep_desync_count'; +SET GLOBAL wsrep_desync = 0; +show status like 'wsrep_desync_count'; + +--disable_query_log +call mtr.add_suppression("Trying to make wsrep_desync = OFF on the node that is already synchronized."); +--enable_query_log +show status like 'wsrep_desync_count'; +SET GLOBAL wsrep_desync = 0; + +SELECT COUNT(*) FROM t1; +SELECT COUNT(*) FROM t2; + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_flush_local.opt b/mysql-test/suite/galera/t/galera_flush_local.opt index 45a0ca24dc7..5a1fb6748d9 100644 --- a/mysql-test/suite/galera/t/galera_flush_local.opt +++ b/mysql-test/suite/galera/t/galera_flush_local.opt @@ -1 +1 @@ ---query_cache_type=1 --query_cache_size=1000000 --userstat=1 --wsrep_replicate_myisam=true +--query_cache_type=1 --query_cache_size=1000000 diff --git a/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test new file mode 100644 index 00000000000..2f27678b547 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test @@ -0,0 +1,150 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# Suppress expected warnings: + +CALL mtr.add_suppression("Aborting"); +CALL mtr.add_suppression("unknown option '--galera-unknown-option'"); + +# +# We should count the number of "Assertion failed" warnings +# in the log file before and after testing. To do this we need +# to save original log file before testing: +# +--let TEST_LOG=$MYSQLTEST_VARDIR/log/mysqld.2.err +--perl + use strict; + my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set"; + my $test_log_copy=$test_log . '.copy'; + if (-e $test_log_copy) { + unlink $test_log_copy; + } +EOF +--copy_file $TEST_LOG $TEST_LOG.copy + +--connection node_2 + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a'); + +SELECT * FROM t1; + +# Initiate normal shutdown on the node 2 and +# waiting until shutdown has been completed: + +--echo Shutting down server ... +--source include/shutdown_mysqld.inc + +--connection node_1 + +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +# Some updates on node 1: + +UPDATE t1 SET f2 = 'b' WHERE f1 > 1; +UPDATE t1 SET f2 = 'c' WHERE f1 > 2; + +SELECT * FROM t1; + +# Remove the "grastate.dat" file (to initiate new SST) +# and restart node 2 with unknown option: + +--connection node_2 + +--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat + +--let $start_mysqld_params=--galera-unknown-option + +--echo Starting server ... +--exec echo "try:$start_mysqld_params" > $_expect_file_name + +# Sleep to ensure that server exited... + +--sleep 30 + +# Restart node 2 without unknown option: + +--let $start_mysqld_params= + +--echo Starting server ... +--source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +# Sanity check (node 2 is running now and can perform SQL operators): + +SELECT * FROM t1; + +# Initiate normal shutdown on the node 2 and +# waiting until shutdown has been completed: + +--echo Shutting down server ... +--source include/shutdown_mysqld.inc + +--connection node_1 + +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +# Some updates on node 1 - to initiate IST next time: + +UPDATE t1 SET f2 = 'd' WHERE f1 > 1; +UPDATE t1 SET f2 = 'd' WHERE f1 > 2; + +SELECT * FROM t1; + +# Restart node 2 with unknown option: + +--connection node_2 + +--let $start_mysqld_params=--galera-unknown-option + +--echo Starting server ... +--exec echo "try:$start_mysqld_params" > $_expect_file_name + +# Sleep to ensure that server exited... + +--sleep 30 + +# Restart node 2 without unknown option: + +--let $start_mysqld_params= + +--echo Starting server ... +--source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +# Sanity check (node 2 is running now and can perform SQL operators): + +SELECT * FROM t1; + +--connection node_1 + +DROP TABLE t1; + +# +# We should count the number of "Assertion failed" warnings +# in the log file during test phase - to print the error message +# if quantity of such warnings in log file increased at the end +# of the test: +# +--perl + use strict; + my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set"; + my $test_log_copy=$test_log . '.copy'; + open(FILE, $test_log_copy) or die("Unable to open $test_log_copy: $!\n"); + my $initial=grep(/Assertion * failed/gi,); + close(FILE); + open(FILE, $test_log) or die("Unable to open $test_log: $!\n"); + my $count_warnings=grep(/Assertion * failed/gi,); + close(FILE); + if ($count_warnings != $initial) { + my $diff=$count_warnings-$initial; + print "Assertion failed $diff times.\n"; + } +EOF +--remove_file $TEST_LOG.copy diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_fk_update.test b/mysql-test/suite/galera/t/galera_toi_ddl_fk_update.test new file mode 100644 index 00000000000..f42fae4ed51 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_ddl_fk_update.test @@ -0,0 +1,49 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# This test creates a new FK constraint while an UPDATE is running +# + +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE parent ( + id INT PRIMARY KEY, + KEY (id) +) ENGINE=InnoDB; + +CREATE TABLE child ( + id INT PRIMARY KEY AUTO_INCREMENT, + parent_id INT +) ENGINE=InnoDB; + +INSERT INTO parent VALUES (1); + +INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +--connection node_1 +--sleep 1 +--send ALTER TABLE child ADD FOREIGN KEY (parent_id) REFERENCES parent(id) ON UPDATE CASCADE; + +--connection node_2 +--sleep 1 +--send UPDATE parent SET id = 2 WHERE id = 1; + +--connection node_1 +--reap + +--connection node_2 +--reap + +--connection node_2 +SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2; + +--connection node_1 +SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2; + +DROP TABLE child; +DROP TABLE parent; + +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_online.test b/mysql-test/suite/galera/t/galera_toi_ddl_online.test new file mode 100644 index 00000000000..af45acc5953 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_ddl_online.test @@ -0,0 +1,53 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# In this test, we run concurrent INSERT against a table against which we have issued concurrent DDL statements that are fully online, +# that is, DDL statements that allow for the DML to proceed non-blocking while the DDL is in progress +# + +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +--connection node_1 +--send INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_1a +--send CREATE INDEX i1 ON t1 (f2); + + +--let $galera_connection_name = node_1b +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_1b +--send ALTER TABLE t1 ADD COLUMN f3 INTEGER; + +--connection node_1 +--reap + +--connection node_1a +--reap + +--connection node_1b +--reap + +--connection node_2 +SELECT COUNT(*) = 200000 FROM t1; +SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; + +--connection node_1 +SELECT COUNT(*) = 200000 FROM t1; +SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_toi_drop_database.test b/mysql-test/suite/galera/t/galera_toi_drop_database.test new file mode 100644 index 00000000000..3176b11dfc0 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_drop_database.test @@ -0,0 +1,54 @@ +# +# Test the operation of DDLs that affect multiple database objects +# + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_1 +CREATE DATABASE database1; +USE database1; + +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; + +# Insert 1M rows +--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +--connection node_1a +USE database1; +--send INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +--connection node_2 +--sleep 1 +--send DROP DATABASE database1; + +--connection node_1 +--sleep 30 +--error ER_NO_SUCH_TABLE +--reap + +--connection node_1a +--error ER_NO_SUCH_TABLE +--reap + +--connection node_2 +--reap + +--connection node_1 +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1'; +--error ER_BAD_DB_ERROR +USE database1; + +--connection node_2 +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1'; +--error ER_BAD_DB_ERROR +USE database1; diff --git a/mysql-test/suite/galera/t/galera_toi_truncate.test b/mysql-test/suite/galera/t/galera_toi_truncate.test new file mode 100644 index 00000000000..2d6027b17c2 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_truncate.test @@ -0,0 +1,77 @@ +# +# Test the operation of TRUNCATE with concurrent DML. Even in the face of a concurrent INSERT, +# the TRUNCATE will complete first and be recorded in the history before the INSERT. +# + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# INSERT and TRUNCATE on different nodes +# + +--connection node_1 +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +# Insert 100K rows +--connection node_2 +--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6; + +--connection node_1 +--sleep 1 +--send TRUNCATE TABLE t1; + +--connection node_1 +--reap + +--connection node_2 +--reap + +--connection node_2 +SELECT COUNT(*) = 1000000 FROM t1; + +--connection node_1 +--let $wait_condition = SELECT COUNT(*) = 1000000 FROM t1; +--source include/wait_condition.inc + +DROP TABLE t1; + +# +# INSERT AND TRUNCATE on same node +# + +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_1 + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +# Insert 100K rows +--connection node_1 +--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6; + +--connection node_1a +--sleep 1 +--send TRUNCATE TABLE t1; + +--connection node_1 +--reap + +--connection node_1a +--reap + +--connection node_1 +SELECT COUNT(*) = 1000000 FROM t1; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1000000 FROM t1; +--source include/wait_condition.inc + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_wsrep_provider_options_syntax.test b/mysql-test/suite/galera/t/galera_wsrep_provider_options_syntax.test new file mode 100644 index 00000000000..fe1abcf6c35 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wsrep_provider_options_syntax.test @@ -0,0 +1,20 @@ +# +# PXC-318: Typo in wsrep_provider_options causes an unhandled exception +# +--source include/galera_cluster.inc +--source include/have_innodb.inc +--let LOGF=$MYSQLTEST_VARDIR/log/mysqld.1.err +--disable_info +call mtr.add_suppression("WSREP\: Unknown parameter 'gmcasts\.segment'"); +call mtr.add_suppression("WSREP\: Set options returned 7"); +--error ER_WRONG_ARGUMENTS +SET GLOBAL wsrep_provider_options="gmcasts.segment=1"; +# Search for unhandled exception message. +perl; + use strict; + my $logf= $ENV{'LOGF'} or die "LOGF not set"; + open(FILE, "$logf") or die("Unable to open $logf: $!\n"); + my $count_warnings=grep(/terminate called after throwing an instance of /gi,); + print "Unhandled exceptions: $count_warnings\n"; + close(FILE); +EOF diff --git a/mysql-test/suite/galera/t/lp1376747-2.test b/mysql-test/suite/galera/t/lp1376747-2.test new file mode 100644 index 00000000000..360681d7674 --- /dev/null +++ b/mysql-test/suite/galera/t/lp1376747-2.test @@ -0,0 +1,22 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +FLUSH TABLES t1 FOR EXPORT; + +--connection node_1 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +INSERT INTO t1 VALUES (2,3); + +--connection node_2 +UNLOCK TABLES; + +--echo ### t1 should have column f2 +SHOW CREATE TABLE t1; +SELECT * from t1; + +--connection node_1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/lp1376747-3.test b/mysql-test/suite/galera/t/lp1376747-3.test new file mode 100644 index 00000000000..75fe7d276cd --- /dev/null +++ b/mysql-test/suite/galera/t/lp1376747-3.test @@ -0,0 +1,28 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +FLUSH TABLE WITH READ LOCK; +--echo ### This shouldn't block. +FLUSH TABLES t1 FOR EXPORT; + +--connection node_1 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connection node_2 +UNLOCK TABLES; + +--echo ### t1 should have column f2 +SHOW CREATE TABLE t1; + +--connection node_1 +INSERT INTO t1 VALUES (2,3); + +--connection node_2 +SELECT * from t1; + +--connection node_1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/lp1376747-4.test b/mysql-test/suite/galera/t/lp1376747-4.test new file mode 100644 index 00000000000..be56ee5edc1 --- /dev/null +++ b/mysql-test/suite/galera/t/lp1376747-4.test @@ -0,0 +1,53 @@ +# +# Test Flush tables with read lock along with +# flush tables with read lock for compatibility. +# Also, making sure all DDL and DMLs are propagated +# after provider is unpaused +# +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc + +--connection node_1 +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +SET session wsrep_sync_wait=0; +SET session wsrep_causal_reads=OFF; +FLUSH TABLE WITH READ LOCK; + +--connection node_1 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +INSERT INTO t1 VALUES (2,3); + +--connection node_2a +SET session wsrep_sync_wait=0; +SET session wsrep_causal_reads=OFF; +SHOW CREATE TABLE t1; +--sleep 1 +--send FLUSH TABLES t1 WITH READ LOCK; + +--connection node_2 +# let the flush table wait in pause state before we unlock +# table otherwise there is window where-in flush table is +# yet to wait in pause and unlock allows alter table to proceed. +# this is because send in asynchronous. +--sleep 3 +# this will release existing lock but will not resume +# the cluster as there is new FTRL that is still pausing it. +UNLOCK TABLES; +SHOW CREATE TABLE t1; + +--connection node_2a +--reap +UNLOCK TABLES; +--sleep 1 +SHOW CREATE TABLE t1; +SELECT * from t1; + +--connection node_1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/lp1376747.test b/mysql-test/suite/galera/t/lp1376747.test new file mode 100644 index 00000000000..769bb665c77 --- /dev/null +++ b/mysql-test/suite/galera/t/lp1376747.test @@ -0,0 +1,24 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +FLUSH TABLES t1 WITH READ LOCK; + +--connection node_1 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +INSERT INTO t1 VALUES (2,3); + +--sleep 2 + +--connection node_2 +UNLOCK TABLES; + +--echo ### t1 should have column f2 +SHOW CREATE TABLE t1; +SELECT * from t1; + +--connection node_1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/pxc-421.test b/mysql-test/suite/galera/t/pxc-421.test new file mode 100644 index 00000000000..8a360b12f4c --- /dev/null +++ b/mysql-test/suite/galera/t/pxc-421.test @@ -0,0 +1,60 @@ +# +# PXC-421: Test deadlock involving updates of +# wsrep_provider, wsrep_cluster_address and wsrep_slave_threads. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +--let $wsrep_slave_1 = `SELECT @@wsrep_slave_threads` +set GLOBAL wsrep_slave_threads=26; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 (f1) SELECT * from t1 as x1; + +--connection node_2 +--let $wsrep_slave_2 = `SELECT @@wsrep_slave_threads` +set GLOBAL wsrep_slave_threads=16; +--let $wsrep_provider_orig = `SELECT @@wsrep_provider` +--let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` + +SET GLOBAL wsrep_provider='none'; +INSERT INTO t1 VALUES (2); + +--connection node_1 +INSERT INTO t1 VALUES (3); + +--connection node_2 +--disable_query_log +--eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig'; +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; +--enable_query_log + +--source include/wait_until_connected_again.inc +--source include/galera_wait_ready.inc + +INSERT INTO t1 VALUES (4); +set GLOBAL wsrep_slave_threads=5; + +# Node #2 has all the inserts +SELECT COUNT(*) = 5 FROM t1; + +--connection node_1 +set GLOBAL wsrep_slave_threads=12; +# Node #1 is missing the insert made while Node #2 was not replicated +SELECT COUNT(*) = 4 FROM t1; +INSERT INTO t1 VALUES (100), (101), (102); + +--connection node_2 +set GLOBAL wsrep_slave_threads=5; +INSERT INTO t1 (f1) SELECT * from t1 as x1; +show global variables like 'wsrep_slave_threads'; +--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_2 +SELECT COUNT(*) FROM t1; + +--connection node_1 +SELECT COUNT(*) FROM t1; +show global variables like 'wsrep_slave_threads'; +--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_1 +DROP TABLE t1; From 3de28b42b406c8093d23fe1de62a6147f30565c6 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 14 Sep 2016 14:33:59 +0300 Subject: [PATCH 03/52] Bump WSREP_PATCH_VERSION to 17 --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index 067a9f128a2..488061e4951 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -26,7 +26,7 @@ ENDIF() OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default}) # Set the patch version -SET(WSREP_PATCH_VERSION "16") +SET(WSREP_PATCH_VERSION "17") # Obtain wsrep API version FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/wsrep_api.h" WSREP_API_VERSION From e043029aaa467305ae25df0f48818eeed9980047 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Mon, 3 Oct 2016 03:09:49 -0700 Subject: [PATCH 04/52] Galera MTR Tests: Test for GCF-942 - safe_to_bootstrap flag in grastate.dat --- .../r/galera_safe_to_bootstrap.result | 26 +++ .../t/galera_safe_to_bootstrap.test | 163 ++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result create mode 100644 mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test diff --git a/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result b/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result new file mode 100644 index 00000000000..21f747d280b --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result @@ -0,0 +1,26 @@ +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 1'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +SET SESSION wsrep_on = OFF; +Killing server ... +safe_to_bootstrap: 1 +safe_to_bootstrap: 0 +safe_to_bootstrap: 0 +CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); +CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test b/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test new file mode 100644 index 00000000000..7c9991e68c4 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test @@ -0,0 +1,163 @@ +# +# Test the safe_to_bootstrap in grastate.dat +# + +--source include/galera_cluster.inc +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +# +# At start, all grastate.dat files have safe_to_boostrap: 0 +# + +--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 0' +--let $assert_select= safe_to_bootstrap: 0 +--let $assert_count= 1 + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat +--source include/assert_grep.inc + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat +--source include/assert_grep.inc + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat +--source include/assert_grep.inc + +# +# Shut down one node +# + +--connection node_2 +--source include/shutdown_mysqld.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +# Still, all grastate.dat files should have safe_to_boostrap: 0 + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat +--source include/assert_grep.inc + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat +--source include/assert_grep.inc + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat +--source include/assert_grep.inc + +# +# Shut down one more node +# + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--connection node_3 +--source include/shutdown_mysqld.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +# Now, nodes 2,3 should have safe_to_boostrap: 0 + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat +--source include/assert_grep.inc + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat +--source include/assert_grep.inc + +# But node #1 should have safe_to_boostrap: 1 + +--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 1' +--let $assert_select= safe_to_bootstrap: 1 + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat +--source include/assert_grep.inc + +# Restart one node + +--connection node_2 +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--source include/start_mysqld.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +# All nodes should be back to 'safe_to_bootstrap: 0' + +--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 0' +--let $assert_select= safe_to_bootstrap: 0 + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat +--source include/assert_grep.inc + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat +--source include/assert_grep.inc + +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat +--source include/assert_grep.inc + +# +# Kill the cluster +# + +--connection node_2 +--source include/shutdown_mysqld.inc + +--connection node_1 +SET SESSION wsrep_on = OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--source include/kill_galera.inc + +# +# Only node #1 should have safe_to_bootstrap: 1 +# include/assert_grep.inc requires a running server, so we revert to simple grep +# + +--error 0 +--exec grep 'safe_to_bootstrap: 1' $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat + +--error 0 +--exec grep 'safe_to_bootstrap: 0' $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat + +--error 0 +--exec grep 'safe_to_bootstrap: 0' $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat + +# +# Attempt to bootstrap nodes #2, #3, should fail +# + +--error 1 +--exec $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster | grep 'This node is not safe to bootstrap the cluster' +--error 1 +--exec $MYSQLD --defaults-group-suffix=.3 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster | grep 'This node is not safe to bootstrap the cluster' + +# +# Attempt to bootstrap starting from node #1, should succeed +# + +--connection node_1 +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--source include/start_mysqld.inc +--source include/wait_until_connected_again.inc + +--connection node_2 +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--source include/start_mysqld.inc + +--connection node_3 +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.3.expect +--source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); + +--connection node_3 +CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); +SHOW CREATE TABLE t1; + +DROP TABLE t1; From 09d8fbc0cf0723f1689a293fe94b8626eac8cd9d Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 11 Oct 2016 03:37:42 -0700 Subject: [PATCH 05/52] Galera MTR Tests: GCF-981 - galera_bf_abort is non deterministic --- mysql-test/suite/galera/r/galera_bf_abort.result | 8 ++++---- mysql-test/suite/galera/t/galera_bf_abort.test | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_bf_abort.result b/mysql-test/suite/galera/r/galera_bf_abort.result index c55f1a4dfcb..cc750f05050 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort.result +++ b/mysql-test/suite/galera/r/galera_bf_abort.result @@ -1,9 +1,9 @@ -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(6)) ENGINE=InnoDB; SET AUTOCOMMIT=OFF; START TRANSACTION; -INSERT INTO t1 VALUES (1); -INSERT INTO t1 VALUES (1); -INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (1,'node_2'); +INSERT INTO t1 VALUES (1,'node_1'); +INSERT INTO t1 VALUES (2, 'node_2'); ERROR 40001: Deadlock found when trying to get lock; try restarting transaction wsrep_local_aborts_increment 1 diff --git a/mysql-test/suite/galera/t/galera_bf_abort.test b/mysql-test/suite/galera/t/galera_bf_abort.test index 69825ea4919..f3476fba490 100644 --- a/mysql-test/suite/galera/t/galera_bf_abort.test +++ b/mysql-test/suite/galera/t/galera_bf_abort.test @@ -5,20 +5,25 @@ # Test a local transaction being aborted by a slave one # -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(6)) ENGINE=InnoDB; +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 --connection node_2 --let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` SET AUTOCOMMIT=OFF; START TRANSACTION; -INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1,'node_2'); --connection node_1 -INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1,'node_1'); + +--connection node_2a +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'node_1' +--source include/wait_condition.inc --connection node_2 --error ER_LOCK_DEADLOCK -INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2, 'node_2'); --let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` From 9b13147d725b0c5c21319c22dd860c7004bfdd5c Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Wed, 22 Mar 2017 11:41:47 +0530 Subject: [PATCH 06/52] Galera MTR Tests: MW-308 , MW-307, GCF-992 * a dedicated test for wsrep_retry_autocommit * some galera_toi_* tests were only passing because wsrep_retry_autocommit was in effect. The tests were changed to do not use autocommit * higher timeout values in galera_2nodes.cnf , galera_3nodes.cnf Signed-off-by: Sachin Setiya --- mysql-test/suite/galera/galera_2nodes.cnf | 9 +- .../suite/galera/r/galera_defaults.result | 2 +- .../galera/r/galera_toi_ddl_online.result | 27 ------ .../galera/r/galera_toi_drop_database.result | 6 +- .../suite/galera/r/galera_toi_truncate.result | 14 ++- .../r/galera_var_retry_autocommit.result | 32 ++++++ .../suite/galera/t/galera_toi_ddl_online.test | 53 ---------- .../galera/t/galera_toi_drop_database.test | 12 ++- .../suite/galera/t/galera_toi_truncate.test | 48 ++------- .../galera/t/galera_var_retry_autocommit.test | 97 +++++++++++++++++++ .../suite/galera_3nodes/galera_3nodes.cnf | 8 +- 11 files changed, 168 insertions(+), 140 deletions(-) delete mode 100644 mysql-test/suite/galera/r/galera_toi_ddl_online.result create mode 100644 mysql-test/suite/galera/r/galera_var_retry_autocommit.result delete mode 100644 mysql-test/suite/galera/t/galera_toi_ddl_online.test create mode 100644 mysql-test/suite/galera/t/galera_var_retry_autocommit.test diff --git a/mysql-test/suite/galera/galera_2nodes.cnf b/mysql-test/suite/galera/galera_2nodes.cnf index e5cf769a910..34bf1fc58fe 100644 --- a/mysql-test/suite/galera/galera_2nodes.cnf +++ b/mysql-test/suite/galera/galera_2nodes.cnf @@ -25,7 +25,14 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' #ist_port=@OPT.port #sst_port=@OPT.port wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' -wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S' + +# enforce read-committed characteristics across the cluster +wsrep_causal_reads=ON +wsrep_sync_wait = 7 + +wsrep_node_address=127.0.0.1 +wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index b6a16f72ec3..6e041224fcc 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -50,7 +50,7 @@ WSREP_SST_DONOR WSREP_SST_DONOR_REJECTS_QUERIES OFF WSREP_SST_METHOD rsync WSREP_SYNC_WAIT 7 -; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; +; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ;gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_online.result b/mysql-test/suite/galera/r/galera_toi_ddl_online.result deleted file mode 100644 index 488b72ab843..00000000000 --- a/mysql-test/suite/galera/r/galera_toi_ddl_online.result +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE ten (f1 INTEGER); -INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; -INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; -CREATE INDEX i1 ON t1 (f2);; -ALTER TABLE t1 ADD COLUMN f3 INTEGER;; -SELECT COUNT(*) = 200000 FROM t1; -COUNT(*) = 200000 -1 -SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 3 -1 -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -SELECT COUNT(*) = 200000 FROM t1; -COUNT(*) = 200000 -1 -SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 3 -1 -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -DROP TABLE t1; -DROP TABLE ten; diff --git a/mysql-test/suite/galera/r/galera_toi_drop_database.result b/mysql-test/suite/galera/r/galera_toi_drop_database.result index d4f98c38847..8f4098419eb 100644 --- a/mysql-test/suite/galera/r/galera_toi_drop_database.result +++ b/mysql-test/suite/galera/r/galera_toi_drop_database.result @@ -4,12 +4,14 @@ CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +SET SESSION wsrep_retry_autocommit = 0; INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; USE database1; +SET SESSION wsrep_retry_autocommit = 0; INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; DROP DATABASE database1;; -ERROR 42S02: Table 'database1.t1' doesn't exist -ERROR 42S02: Table 'database1.t2' doesn't exist +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1'; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera_toi_truncate.result b/mysql-test/suite/galera/r/galera_toi_truncate.result index 98bc9f4850b..f52316f3cbc 100644 --- a/mysql-test/suite/galera/r/galera_toi_truncate.result +++ b/mysql-test/suite/galera/r/galera_toi_truncate.result @@ -1,17 +1,15 @@ CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +SET SESSION wsrep_retry_autocommit = 0; INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;; TRUNCATE TABLE t1;; -SELECT COUNT(*) = 1000000 FROM t1; -COUNT(*) = 1000000 +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 1 -DROP TABLE t1; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;; -TRUNCATE TABLE t1;; -SELECT COUNT(*) = 1000000 FROM t1; -COUNT(*) = 1000000 +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 1 DROP TABLE t1; DROP TABLE ten; diff --git a/mysql-test/suite/galera/r/galera_var_retry_autocommit.result b/mysql-test/suite/galera/r/galera_var_retry_autocommit.result new file mode 100644 index 00000000000..f4d17ad9a41 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_var_retry_autocommit.result @@ -0,0 +1,32 @@ +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5); +SET SESSION wsrep_retry_autocommit = 0; +INSERT INTO t1 (f1) VALUES (1),(2);; +TRUNCATE TABLE t1; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SET SESSION wsrep_retry_autocommit = 1; +INSERT INTO t1 (f1) VALUES (3),(4);; +TRUNCATE TABLE t1; +SELECT * FROM test.t1; +f1 f2 +3 0 +4 0 +CREATE PROCEDURE repeated_truncate () +BEGIN +DECLARE i INT; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET i = 0; +WHILE i <= 1000 DO +TRUNCATE TABLE t1; +SET i = i + 1; +END WHILE; +END| +CALL repeated_truncate(); +SET SESSION wsrep_retry_autocommit = 1; +INSERT INTO t1 (f1) VALUES (5),(6); +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SET SESSION wsrep_retry_autocommit = 1024; +INSERT INTO t1 (f1) VALUES (7),(8);; +include/diff_servers.inc [servers=1 2] +DROP TABLE t1; +DROP PROCEDURE repeated_truncate; diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_online.test b/mysql-test/suite/galera/t/galera_toi_ddl_online.test deleted file mode 100644 index af45acc5953..00000000000 --- a/mysql-test/suite/galera/t/galera_toi_ddl_online.test +++ /dev/null @@ -1,53 +0,0 @@ ---source include/galera_cluster.inc ---source include/have_innodb.inc - -# -# In this test, we run concurrent INSERT against a table against which we have issued concurrent DDL statements that are fully online, -# that is, DDL statements that allow for the DML to proceed non-blocking while the DDL is in progress -# - -CREATE TABLE ten (f1 INTEGER); -INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; - ---connection node_1 ---send INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; - ---let $galera_connection_name = node_1a ---let $galera_server_number = 1 ---source include/galera_connect.inc - ---connection node_1a ---send CREATE INDEX i1 ON t1 (f2); - - ---let $galera_connection_name = node_1b ---let $galera_server_number = 1 ---source include/galera_connect.inc - ---connection node_1b ---send ALTER TABLE t1 ADD COLUMN f3 INTEGER; - ---connection node_1 ---reap - ---connection node_1a ---reap - ---connection node_1b ---reap - ---connection node_2 -SELECT COUNT(*) = 200000 FROM t1; -SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; - ---connection node_1 -SELECT COUNT(*) = 200000 FROM t1; -SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; - -DROP TABLE t1; -DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_toi_drop_database.test b/mysql-test/suite/galera/t/galera_toi_drop_database.test index 3176b11dfc0..0a37a4010ce 100644 --- a/mysql-test/suite/galera/t/galera_toi_drop_database.test +++ b/mysql-test/suite/galera/t/galera_toi_drop_database.test @@ -2,7 +2,6 @@ # Test the operation of DDLs that affect multiple database objects # ---source include/big_test.inc --source include/galera_cluster.inc --source include/have_innodb.inc @@ -20,11 +19,14 @@ INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -# Insert 1M rows +# Make sure autocommit retrying does not kick in as this will mask the error we expect to get +SET SESSION wsrep_retry_autocommit = 0; +# Attemp to insert 1M rows --send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; --connection node_1a USE database1; +SET SESSION wsrep_retry_autocommit = 0; --send INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; --connection node_2 @@ -32,12 +34,12 @@ USE database1; --send DROP DATABASE database1; --connection node_1 ---sleep 30 ---error ER_NO_SUCH_TABLE +--sleep 1 +--error ER_LOCK_DEADLOCK --reap --connection node_1a ---error ER_NO_SUCH_TABLE +--error ER_LOCK_DEADLOCK --reap --connection node_2 diff --git a/mysql-test/suite/galera/t/galera_toi_truncate.test b/mysql-test/suite/galera/t/galera_toi_truncate.test index 2d6027b17c2..59ef5c2028f 100644 --- a/mysql-test/suite/galera/t/galera_toi_truncate.test +++ b/mysql-test/suite/galera/t/galera_toi_truncate.test @@ -1,9 +1,8 @@ # -# Test the operation of TRUNCATE with concurrent DML. Even in the face of a concurrent INSERT, -# the TRUNCATE will complete first and be recorded in the history before the INSERT. +# Test the operation of TRUNCATE with concurrent DML. +# The DML should be BF-aborted if the DDL arrives from another node # ---source include/big_test.inc --source include/galera_cluster.inc --source include/have_innodb.inc @@ -19,6 +18,8 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; # Insert 100K rows --connection node_2 +# Prevent autocommit retring from masking the deadlock error we expect to get +SET SESSION wsrep_retry_autocommit = 0; --send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6; --connection node_1 @@ -29,49 +30,14 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; --reap --connection node_2 +--error ER_LOCK_DEADLOCK --reap --connection node_2 -SELECT COUNT(*) = 1000000 FROM t1; +SELECT COUNT(*) = 0 FROM t1; --connection node_1 ---let $wait_condition = SELECT COUNT(*) = 1000000 FROM t1; ---source include/wait_condition.inc - -DROP TABLE t1; - -# -# INSERT AND TRUNCATE on same node -# - ---let $galera_connection_name = node_1a ---let $galera_server_number = 1 ---source include/galera_connect.inc - ---connection node_1 - -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; - -# Insert 100K rows ---connection node_1 ---send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6; - ---connection node_1a ---sleep 1 ---send TRUNCATE TABLE t1; - ---connection node_1 ---reap - ---connection node_1a ---reap - ---connection node_1 -SELECT COUNT(*) = 1000000 FROM t1; - ---connection node_2 ---let $wait_condition = SELECT COUNT(*) = 1000000 FROM t1; ---source include/wait_condition.inc +SELECT COUNT(*) = 0 FROM t1; DROP TABLE t1; DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_var_retry_autocommit.test b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test new file mode 100644 index 00000000000..6ef647b24e1 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test @@ -0,0 +1,97 @@ +# +# Test that the wsrep_retry_autocommit variable is respected. We use an INSERT that +# proceeds very slowly due to extra SLEEP() in a trigger +# + +--source include/galera_cluster.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5); + +# +# With wsrep_retry_autocommit = 0, error is certain +# + +--connection node_1 +SET SESSION wsrep_retry_autocommit = 0; +--send INSERT INTO t1 (f1) VALUES (1),(2); + +--connection node_2 +--sleep 1 +TRUNCATE TABLE t1; + +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +# +# With wsrep_retry_autocommit = 1, success against one TRUNCATE +# + +--connection node_1 +SET SESSION wsrep_retry_autocommit = 1; +--send INSERT INTO t1 (f1) VALUES (3),(4); + +--connection node_2 +--sleep 1 +TRUNCATE TABLE t1; + +--connection node_1 +--error 0 +--reap +SELECT * FROM test.t1; + +# +# With wsrep_retry_autocommit = 1, failure against multiple TRUNCATEs +# + +--connection node_2 +DELIMITER |; +CREATE PROCEDURE repeated_truncate () +BEGIN + DECLARE i INT; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + + SET i = 0; + WHILE i <= 1000 DO + TRUNCATE TABLE t1; + SET i = i + 1; + END WHILE; +END| +DELIMITER ;| + +# Begin streaming TRUNCATEs +--let $truncate_connection_id = `SELECT CONNECTION_ID()` +--send CALL repeated_truncate() + +--connection node_1 +SET SESSION wsrep_retry_autocommit = 1; +--sleep 1 +--error ER_LOCK_DEADLOCK +INSERT INTO t1 (f1) VALUES (5),(6); + +# +# With wsrep_retry_autocommit = 1024, success against multiple TRUNCATEs +# + +--connection node_1 +SET SESSION wsrep_retry_autocommit = 1024; +--send INSERT INTO t1 (f1) VALUES (7),(8); + +--sleep 6 + +# Once he stream of TRUNCATEs is complete +--connection node_2 +--reap + +# the INSERT will eventually be sucessfull +--connection node_1 +--error 0 +--reap + +--let $diff_servers = 1 2 +--source include/diff_servers.inc + +DROP TABLE t1; +DROP PROCEDURE repeated_truncate; diff --git a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf index eaa2899968c..1ed273fdcb5 100644 --- a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf +++ b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf @@ -27,7 +27,9 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' #ist_port=@OPT.port #sst_port=@OPT.port wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' -wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' +wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S' + +wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' @@ -36,7 +38,9 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' #ist_port=@OPT.port #sst_port=@OPT.port wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' -wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S' + +wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' From 07fe265a4775b46d40051e6880a319992ee9ec16 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 2 Nov 2016 02:01:10 -0700 Subject: [PATCH 07/52] Galera MTR Tests: GAL-405 Initial implementation of GCache recovery on startup. --- .../suite/galera/r/galera_defaults.result | 2 +- .../galera/r/galera_gcache_recover.result | 18 ++ .../galera_gcache_recover_full_gcache.result | 19 ++ .../r/galera_gcache_recover_manytrx.result | 107 +++++++++ .../suite/galera/t/galera_gcache_recover.cnf | 7 + .../suite/galera/t/galera_gcache_recover.test | 77 +++++++ .../t/galera_gcache_recover_full_gcache.cnf | 9 + .../t/galera_gcache_recover_full_gcache.test | 59 +++++ .../t/galera_gcache_recover_manytrx.cnf | 8 + .../t/galera_gcache_recover_manytrx.test | 216 ++++++++++++++++++ 10 files changed, 521 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera/r/galera_gcache_recover.result create mode 100644 mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result create mode 100644 mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result create mode 100644 mysql-test/suite/galera/t/galera_gcache_recover.cnf create mode 100644 mysql-test/suite/galera/t/galera_gcache_recover.test create mode 100644 mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.cnf create mode 100644 mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test create mode 100644 mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf create mode 100644 mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index 6e041224fcc..aa31aa52d6b 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -50,7 +50,7 @@ WSREP_SST_DONOR WSREP_SST_DONOR_REJECTS_QUERIES OFF WSREP_SST_METHOD rsync WSREP_SYNC_WAIT 7 -; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ;gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; +; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.recover = no; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ;gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; diff --git a/mysql-test/suite/galera/r/galera_gcache_recover.result b/mysql-test/suite/galera/r/galera_gcache_recover.result new file mode 100644 index 00000000000..127bcba39d8 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_gcache_recover.result @@ -0,0 +1,18 @@ +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_sync_wait = 0; +Killing server ... +INSERT INTO t1 VALUES (2); +Killing server ... +Performing --wsrep-recover ... +Using --wsrep-start-position when starting mysqld ... +INSERT INTO t1 VALUES (3); +Performing --wsrep-recover ... +Using --wsrep-start-position when starting mysqld ... +include/diff_servers.inc [servers=1 2] +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); +include/assert_grep.inc [async IST sender starting to serve] +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); +include/assert_grep.inc [Recovering GCache ring buffer: found gapless sequence] +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result b/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result new file mode 100644 index 00000000000..30ee5772411 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result @@ -0,0 +1,19 @@ +SET SESSION wsrep_sync_wait = 0; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; +SET SESSION wsrep_sync_wait = 0; +Killing server ... +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +Killing server ... +Performing --wsrep-recover ... +Using --wsrep-start-position when starting mysqld ... +Performing --wsrep-recover ... +Using --wsrep-start-position when starting mysqld ... +include/diff_servers.inc [servers=1 2] +DROP TABLE t1; +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); +include/assert_grep.inc [IST first seqno 2 not found from cache, falling back to SST] +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); diff --git a/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result b/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result new file mode 100644 index 00000000000..868b39bfbd6 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result @@ -0,0 +1,107 @@ +SET SESSION wsrep_sync_wait = 0; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +CREATE PROCEDURE insert_simple () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +INSERT INTO t1 (f1, f2) VALUES (DEFAULT,'abcdef'); +END WHILE; +END| +CREATE PROCEDURE insert_multi () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +INSERT INTO t1 (f1) VALUES (DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT); +END WHILE; +END| +CREATE PROCEDURE insert_transaction () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +SET AUTOCOMMIT = OFF; +WHILE 1 DO +START TRANSACTION; +INSERT INTO t1 (f1) VALUES (DEFAULT); +INSERT INTO t1 (f1) VALUES (DEFAULT); +INSERT INTO t1 (f1) VALUES (DEFAULT); +INSERT INTO t1 (f1) VALUES (DEFAULT); +INSERT INTO t1 (f1) VALUES (DEFAULT); +INSERT INTO t1 (f1) VALUES (DEFAULT); +INSERT INTO t1 (f1) VALUES (DEFAULT); +INSERT INTO t1 (f1) VALUES (DEFAULT); +INSERT INTO t1 (f1) VALUES (DEFAULT); +INSERT INTO t1 (f1) VALUES (DEFAULT); +COMMIT; +END WHILE; +END| +CREATE PROCEDURE update_simple () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +UPDATE t1 SET f2 = CONCAT(f2,f2); +END WHILE; +END| +CREATE PROCEDURE insert_1k () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024)); +END WHILE; +END| +CREATE PROCEDURE insert_1m () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024)); +END WHILE; +END| +CREATE PROCEDURE insert_10m () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +END WHILE; +END| +CALL insert_simple();; +CALL insert_multi();; +CALL insert_transaction ();; +CALL update_simple ();; +CALL insert_1k ();; +CALL insert_1m ();; +CALL insert_10m ();; +SET SESSION wsrep_sync_wait = 0; +Killing server ... +Killing server ... +ERROR HY000: Lost connection to MySQL server during query +ERROR HY000: Lost connection to MySQL server during query +ERROR HY000: Lost connection to MySQL server during query +ERROR HY000: Lost connection to MySQL server during query +ERROR HY000: Lost connection to MySQL server during query +ERROR HY000: Lost connection to MySQL server during query +ERROR HY000: Lost connection to MySQL server during query +Performing --wsrep-recover ... +Using --wsrep-start-position when starting mysqld ... +Performing --wsrep-recover ... +Using --wsrep-start-position when starting mysqld ... +include/diff_servers.inc [servers=1 2] +DROP TABLE t1; +DROP TABLE ten; +DROP PROCEDURE insert_simple; +DROP PROCEDURE insert_multi; +DROP PROCEDURE insert_transaction; +DROP PROCEDURE update_simple; +DROP PROCEDURE insert_1k; +DROP PROCEDURE insert_1m; +CALL mtr.add_suppression("conflict state 7 after post commit"); +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); +include/assert_grep.inc [async IST sender starting to serve] +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); +include/assert_grep.inc [Recovering GCache ring buffer: found gapless sequence] diff --git a/mysql-test/suite/galera/t/galera_gcache_recover.cnf b/mysql-test/suite/galera/t/galera_gcache_recover.cnf new file mode 100644 index 00000000000..c7b59b6a27e --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcache_recover.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.recover=yes;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.recover=yes;pc.ignore_sb=true' diff --git a/mysql-test/suite/galera/t/galera_gcache_recover.test b/mysql-test/suite/galera/t/galera_gcache_recover.test new file mode 100644 index 00000000000..e1bfe517d27 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcache_recover.test @@ -0,0 +1,77 @@ +# +# Kill entire cluster while gcache.recover=yes. Expect that node #2 will rejoin using IST +# + +--source include/galera_cluster.inc +--source include/big_test.inc + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET SESSION wsrep_sync_wait = 0; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) > 0 FROM t1; +--source include/wait_condition.inc + +SET SESSION wsrep_sync_wait = 0; +--source include/kill_galera.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +INSERT INTO t1 VALUES (2); + +--source include/kill_galera.inc + +--sleep 1 + +--connection node_1 +--let $galera_wsrep_recover_server_id=1 +--source suite/galera/include/galera_wsrep_recover.inc + +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--source include/start_mysqld.inc + +INSERT INTO t1 VALUES (3); + +--connection node_2 +--let $galera_wsrep_recover_server_id=2 +--source suite/galera/include/galera_wsrep_recover.inc + +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--source include/start_mysqld.inc + +--connection node_1 +--source include/wait_until_connected_again.inc +--source include/galera_wait_ready.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +--let $diff_servers = 1 2 +--source include/diff_servers.inc + +--connection node_1 +# Warning happens when the cluster is started for the first time +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); + +# Confirm that IST took place +--let $assert_text = async IST sender starting to serve +--let $assert_select = async IST sender starting to serve +--let $assert_count = 1 +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err +--let $assert_only_after = starting as process +--source include/assert_grep.inc + +--connection node_2 +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); + +# Confirm that gcache recovery took place + +--let $assert_text = Recovering GCache ring buffer: found gapless sequence +--let $assert_select = Recovering GCache ring buffer: found gapless sequence +--let $assert_count = 1 +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err +--let $assert_only_after = starting as process +--source include/assert_grep.inc + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.cnf b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.cnf new file mode 100644 index 00000000000..da74ea9fc5d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.cnf @@ -0,0 +1,9 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +max_allowed_packet=10M +innodb_log_file_size=110M +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.recover=yes;pc.ignore_sb=true;gcache.size=10M' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.recover=yes;pc.ignore_sb=true;gcache.size=10M' diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test new file mode 100644 index 00000000000..b7fd9cf3aed --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test @@ -0,0 +1,59 @@ +# +# Attempt gcache recovery on a full gcache. Node will not be able to join via IST due to gcache rollover +# + +--source include/galera_cluster.inc +--source include/big_test.inc + +SET SESSION wsrep_sync_wait = 0; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; + +--connection node_2 +SET SESSION wsrep_sync_wait = 0; +--source include/kill_galera.inc + +--connection node_1 +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); +--source include/kill_galera.inc + +--connection node_1 +--let $galera_wsrep_recover_server_id=1 +--source suite/galera/include/galera_wsrep_recover.inc + +--let $_expect_file_name = $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--source include/start_mysqld.inc +--connection node_2 +--let $galera_wsrep_recover_server_id=2 +--source suite/galera/include/galera_wsrep_recover.inc + +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--source include/start_mysqld.inc + +--connection node_1 +--source include/wait_until_connected_again.inc +--source include/galera_wait_ready.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +--let $diff_servers = 1 2 +--source include/diff_servers.inc + +--connection node_1 +DROP TABLE t1; + +# Warning always happens when the cluster is started for the first time +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); + +# Confirm that IST did not take place +--let $assert_text = IST first seqno 2 not found from cache, falling back to SST +--let $assert_select = IST first seqno 2 not found from cache, falling back to SST +--let $assert_count = 1 +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err +--let $assert_only_after = starting as process +--source include/assert_grep.inc + +--connection node_2 +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf new file mode 100644 index 00000000000..39af0e94b94 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf @@ -0,0 +1,8 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +innodb_log_file_size=110M +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.recover=yes;pc.ignore_sb=true;' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.recover=yes;pc.ignore_sb=true;' diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test new file mode 100644 index 00000000000..3bfcdc9f117 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test @@ -0,0 +1,216 @@ +# +# Kill entire cluster while various transactions are in progress +# restore the cluster and expect that node #2 will rejoin using IST +# + +--source include/galera_cluster.inc +--source include/big_test.inc + +SET SESSION wsrep_sync_wait = 0; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +DELIMITER |; +CREATE PROCEDURE insert_simple () +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SET SESSION wsrep_sync_wait = 0; + WHILE 1 DO + INSERT INTO t1 (f1, f2) VALUES (DEFAULT,'abcdef'); + END WHILE; +END| + +CREATE PROCEDURE insert_multi () +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SET SESSION wsrep_sync_wait = 0; + WHILE 1 DO + INSERT INTO t1 (f1) VALUES (DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT); + END WHILE; +END| + +CREATE PROCEDURE insert_transaction () +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SET SESSION wsrep_sync_wait = 0; + SET AUTOCOMMIT = OFF; + WHILE 1 DO + START TRANSACTION; + INSERT INTO t1 (f1) VALUES (DEFAULT); + INSERT INTO t1 (f1) VALUES (DEFAULT); + INSERT INTO t1 (f1) VALUES (DEFAULT); + INSERT INTO t1 (f1) VALUES (DEFAULT); + INSERT INTO t1 (f1) VALUES (DEFAULT); + + INSERT INTO t1 (f1) VALUES (DEFAULT); + INSERT INTO t1 (f1) VALUES (DEFAULT); + INSERT INTO t1 (f1) VALUES (DEFAULT); + INSERT INTO t1 (f1) VALUES (DEFAULT); + INSERT INTO t1 (f1) VALUES (DEFAULT); + COMMIT; + END WHILE; +END| + +DELIMITER ;| +DELIMITER |; + +CREATE PROCEDURE update_simple () +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SET SESSION wsrep_sync_wait = 0; + WHILE 1 DO + UPDATE t1 SET f2 = CONCAT(f2,f2); + END WHILE; +END| + +CREATE PROCEDURE insert_1k () +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SET SESSION wsrep_sync_wait = 0; + WHILE 1 DO + INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024)); + END WHILE; +END| + +CREATE PROCEDURE insert_1m () +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SET SESSION wsrep_sync_wait = 0; + WHILE 1 DO + INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024)); + END WHILE; +END| + +CREATE PROCEDURE insert_10m () +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SET SESSION wsrep_sync_wait = 0; + WHILE 1 DO + INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); + END WHILE; +END| + +DELIMITER ;| + +--connect node_1_insert_simple, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_1_insert_multi, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_1_insert_transaction, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_1_update_simple, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_1_insert_1k, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_1_insert_1m, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_1_insert_10m, 127.0.0.1, root, , test, $NODE_MYPORT_1 + +--connection node_1_insert_simple +--send CALL insert_simple(); + +--connection node_1_insert_multi +--send CALL insert_multi(); + +--connection node_1_insert_transaction +--send CALL insert_transaction (); + +--connection node_1_update_simple +--send CALL update_simple (); + +--connection node_1_insert_1k +--send CALL insert_1k (); + +--connection node_1_insert_1m +--send CALL insert_1m (); + +--connection node_1_insert_10m +--send CALL insert_10m (); + +--connection node_2 +SET SESSION wsrep_sync_wait = 0; +--source include/kill_galera.inc + +--sleep 10 +--connection node_1 +--source include/kill_galera.inc + +--connection node_1_insert_simple +--error 2013 +--reap + +--connection node_1_insert_multi +--error 2013 +--reap + +--connection node_1_insert_transaction +--error 2013 +--reap + +--connection node_1_update_simple +--error 2013 +--reap + +--connection node_1_insert_1k +--error 2013 +--reap + +--connection node_1_insert_1m +--error 2013 +--reap + +--connection node_1_insert_10m +--error 2013 +--reap + +--connection node_1 +--let $galera_wsrep_recover_server_id=1 +--source suite/galera/include/galera_wsrep_recover.inc + +--let $_expect_file_name = $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--source include/start_mysqld.inc +--connection node_2 +--let $galera_wsrep_recover_server_id=2 +--source suite/galera/include/galera_wsrep_recover.inc + +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--source include/start_mysqld.inc + +--connection node_1 +--source include/wait_until_connected_again.inc +--source include/galera_wait_ready.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +--let $diff_servers = 1 2 +--source include/diff_servers.inc + +--connection node_1 +DROP TABLE t1; +DROP TABLE ten; +DROP PROCEDURE insert_simple; +DROP PROCEDURE insert_multi; +DROP PROCEDURE insert_transaction; +DROP PROCEDURE update_simple; +DROP PROCEDURE insert_1k; +DROP PROCEDURE insert_1m; + +--connection node_1 +CALL mtr.add_suppression("conflict state 7 after post commit"); + +# Warning happens when the cluster is started for the first time +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); + +# Confirm that IST took place +--let $assert_text = async IST sender starting to serve +--let $assert_select = async IST sender starting to serve +--let $assert_count = 1 +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err +--let $assert_only_after = starting as process +--source include/assert_grep.inc + +--connection node_2 +CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); + +# Confirm that gcache recovery took place + +--let $assert_text = Recovering GCache ring buffer: found gapless sequence +--let $assert_select = Recovering GCache ring buffer: found gapless sequence +--let $assert_count = 1 +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err +--let $assert_only_after = starting as process +--source include/assert_grep.inc From c3e9110033201d2ae3f3a32ee600ecd23c1b1d63 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Thu, 23 Mar 2017 13:43:12 +0530 Subject: [PATCH 08/52] Galera MTR Tests: Tests for GAL-419 Respect safe_to_bootstrap flag also with gcomm:// Signed-off-by: Sachin Setiya --- mysql-test/suite/galera/r/GAL-419.result | 4 +++ .../r/galera_var_cluster_address.result | 25 ++++++++++++- mysql-test/suite/galera/t/GAL-419.test | 35 +++++++++++++++++++ .../galera/t/galera_var_cluster_address.test | 34 ++++++++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera/r/GAL-419.result create mode 100644 mysql-test/suite/galera/t/GAL-419.test diff --git a/mysql-test/suite/galera/r/GAL-419.result b/mysql-test/suite/galera/r/GAL-419.result new file mode 100644 index 00000000000..410c91b4f98 --- /dev/null +++ b/mysql-test/suite/galera/r/GAL-419.result @@ -0,0 +1,4 @@ +SET SESSION wsrep_sync_wait = 0; +Killing server ... +SET SESSION wsrep_sync_wait = 0; +Killing server ... diff --git a/mysql-test/suite/galera/r/galera_var_cluster_address.result b/mysql-test/suite/galera/r/galera_var_cluster_address.result index 17b5a7bca37..8c23b660d4f 100644 --- a/mysql-test/suite/galera/r/galera_var_cluster_address.result +++ b/mysql-test/suite/galera/r/galera_var_cluster_address.result @@ -26,6 +26,28 @@ VARIABLE_VALUE = 'Primary' SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 +SET GLOBAL wsrep_cluster_address = 'gcomm://192.0.2.1'; +SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS; +COUNT(*) > 0 +1 +SHOW STATUS LIKE 'wsrep_ready'; +Variable_name Value +wsrep_ready OFF +SHOW STATUS LIKE 'wsrep_cluster_status'; +Variable_name Value +wsrep_cluster_status non-Primary +SHOW STATUS LIKE 'wsrep_local_state'; +Variable_name Value +wsrep_local_state 0 +SHOW STATUS LIKE 'wsrep_local_state_comment'; +Variable_name Value +wsrep_local_state_comment Initialized +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +VARIABLE_VALUE = 'Primary' +1 +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 2 +1 CALL mtr.add_suppression("Backend not supported: foo"); CALL mtr.add_suppression("Failed to initialize backend using 'foo"); CALL mtr.add_suppression("Failed to open channel 'my_wsrep_cluster' at 'foo"); @@ -36,4 +58,5 @@ CALL mtr.add_suppression("failed to open gcomm backend connection: 110: failed t CALL mtr.add_suppression("Failed to open backend connection: -110 \\(Connection timed out\\)"); CALL mtr.add_suppression("gcs connect failed: Connection timed out"); CALL mtr.add_suppression("WSREP: wsrep::connect\\(foo://\\) failed: 7"); -# End of test +CALL mtr.add_suppression("WSREP: wsrep::connect\\(gcomm://192.0.2.1\\) failed: 7"); +# End of test \ No newline at end of file diff --git a/mysql-test/suite/galera/t/GAL-419.test b/mysql-test/suite/galera/t/GAL-419.test new file mode 100644 index 00000000000..e50b948bf35 --- /dev/null +++ b/mysql-test/suite/galera/t/GAL-419.test @@ -0,0 +1,35 @@ +# +# GAL-419 safe_to_bootstrap: boostrap using wsrep_cluster_address=gcomm:// not prevented +# + +--source include/galera_cluster.inc +--source include/big_test.inc + +--connection node_2 +SET SESSION wsrep_sync_wait = 0; +--source include/kill_galera.inc + +--connection node_1 +SET SESSION wsrep_sync_wait = 0; +--source include/kill_galera.inc + +--sleep 2 + +# Node #1 has wsrep_cluster_address=gcomm:// in my.cnf, so should fail to bootstrap + +--error 1 +--exec $MYSQLD --defaults-group-suffix=.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf | grep 'This node is not safe to bootstrap the cluster' + +# Unless we remove grastate.dat + +--remove_file $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat +--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat + +--connection node_1 +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--source include/start_mysqld.inc +--source include/wait_until_connected_again.inc + +--connection node_2 +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--source include/start_mysqld.inc diff --git a/mysql-test/suite/galera/t/galera_var_cluster_address.test b/mysql-test/suite/galera/t/galera_var_cluster_address.test index 740c38765f6..e5428fb9c6c 100644 --- a/mysql-test/suite/galera/t/galera_var_cluster_address.test +++ b/mysql-test/suite/galera/t/galera_var_cluster_address.test @@ -58,6 +58,39 @@ SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VA SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +# +# Set to invalid host +# + +--connection node_2 +SET GLOBAL wsrep_cluster_address = 'gcomm://192.0.2.1'; + +--error 0 +SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS; + +# Must return 'OFF' +SHOW STATUS LIKE 'wsrep_ready'; + +# Must return 'Non-primary' +SHOW STATUS LIKE 'wsrep_cluster_status'; + +# Must return 0 = 'Initialized' +SHOW STATUS LIKE 'wsrep_local_state'; +SHOW STATUS LIKE 'wsrep_local_state_comment'; + +# +# Reset everything as it was +# + +--connection node_2 +--disable_query_log +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_node2'; +--enable_query_log + +--connection node_1 +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + --connection node_2 CALL mtr.add_suppression("Backend not supported: foo"); CALL mtr.add_suppression("Failed to initialize backend using 'foo"); @@ -69,6 +102,7 @@ CALL mtr.add_suppression("failed to open gcomm backend connection: 110: failed t CALL mtr.add_suppression("Failed to open backend connection: -110 \\(Connection timed out\\)"); CALL mtr.add_suppression("gcs connect failed: Connection timed out"); CALL mtr.add_suppression("WSREP: wsrep::connect\\(foo://\\) failed: 7"); +CALL mtr.add_suppression("WSREP: wsrep::connect\\(gcomm://192.0.2.1\\) failed: 7"); # Restore original auto_increment_offset values. --source include/auto_increment_offset_restore.inc From 0f6aa6ba6609c135b0f69aa56b45f9ebe80c4258 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 2 Nov 2016 07:04:34 -0700 Subject: [PATCH 09/52] Galera MTR tests: Update galera_defaults.result for GAL-360 --- mysql-test/suite/galera/r/galera_defaults.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index aa31aa52d6b..cb306734002 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -50,7 +50,7 @@ WSREP_SST_DONOR WSREP_SST_DONOR_REJECTS_QUERIES OFF WSREP_SST_METHOD rsync WSREP_SYNC_WAIT 7 -; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.recover = no; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ;gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; +; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.recover = no; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ;gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; From f94c9b02cf91bd3ffb5381e7168ab554d3657c83 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Thu, 3 Nov 2016 04:05:05 -0700 Subject: [PATCH 10/52] Galera MTR Tests: MW-305 , re-enable the test for ALTER USER --- .../galera/r/galera_account_management.result | 7 +++++++ .../suite/galera/t/galera_account_management.test | 14 ++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_account_management.result b/mysql-test/suite/galera/r/galera_account_management.result index 9b3ae9ba46e..4fa33a63064 100644 --- a/mysql-test/suite/galera/r/galera_account_management.result +++ b/mysql-test/suite/galera/r/galera_account_management.result @@ -2,6 +2,13 @@ CREATE USER user1, user2 IDENTIFIED BY 'password'; SELECT COUNT(*) = 2 FROM mysql.user WHERE user IN ('user1', 'user2'); COUNT(*) = 2 1 +ALTER USER user1 PASSWORD EXPIRE; +SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; +password_expired = 'Y' +1 +SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; +password_expired = 'Y' +1 RENAME USER user2 TO user3; SELECT COUNT(*) = 0 FROM mysql.user WHERE user = 'user2'; COUNT(*) = 0 diff --git a/mysql-test/suite/galera/t/galera_account_management.test b/mysql-test/suite/galera/t/galera_account_management.test index 357319ad106..6dea0fcfa9e 100644 --- a/mysql-test/suite/galera/t/galera_account_management.test +++ b/mysql-test/suite/galera/t/galera_account_management.test @@ -18,14 +18,12 @@ SELECT COUNT(*) = 2 FROM mysql.user WHERE user IN ('user1', 'user2'); # ALTER USER # -# LP bug 1376269 -# -#--connection node_1 -#ALTER USER user1 PASSWORD EXPIRE; -#SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; -# -#--connection node_2 -#SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; +--connection node_1 +ALTER USER user1 PASSWORD EXPIRE; +SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; + +--connection node_2 +SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; # # RENAME USER From c72e1ea940d0dc0a78445e401b2933a46c5144b9 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 4 Nov 2016 01:33:54 -0700 Subject: [PATCH 11/52] Galera MTR Tests: Test for MW-313 Enforce wsrep_max_ws_rows also when binlog is enabled --- mysql-test/suite/galera/r/MW-313.result | 32 +++++++++++++ mysql-test/suite/galera/t/MW-313-master.opt | 1 + mysql-test/suite/galera/t/MW-313.test | 50 +++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-313.result create mode 100644 mysql-test/suite/galera/t/MW-313-master.opt create mode 100644 mysql-test/suite/galera/t/MW-313.test diff --git a/mysql-test/suite/galera/r/MW-313.result b/mysql-test/suite/galera/r/MW-313.result new file mode 100644 index 00000000000..dc605ffc370 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-313.result @@ -0,0 +1,32 @@ +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET GLOBAL wsrep_max_ws_rows = 2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +SELECT * FROM t1 GROUP BY f1; +f1 +1 +SELECT * FROM t1 GROUP BY f1; +f1 +1 +SELECT * FROM t1 GROUP BY f1; +f1 +1 +SHOW STATUS LIKE '%wsrep%'; +INSERT INTO t1 SELECT * FROM t1; +ERROR HY000: wsrep_max_ws_rows exceeded +START TRANSACTION; +INSERT INTO t1 (f1) VALUES (1); +INSERT INTO t1 (f1) VALUES (2),(3),(4); +ERROR HY000: wsrep_max_ws_rows exceeded +ROLLBACK; +START TRANSACTION; +DELETE FROM t1; +ERROR HY000: wsrep_max_ws_rows exceeded +DROP TABLE t1; +SET GLOBAL wsrep_max_ws_rows = 0; diff --git a/mysql-test/suite/galera/t/MW-313-master.opt b/mysql-test/suite/galera/t/MW-313-master.opt new file mode 100644 index 00000000000..8a755e98b00 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-313-master.opt @@ -0,0 +1 @@ +--log-bin --log-slave-updates diff --git a/mysql-test/suite/galera/t/MW-313.test b/mysql-test/suite/galera/t/MW-313.test new file mode 100644 index 00000000000..d697cb2cfcd --- /dev/null +++ b/mysql-test/suite/galera/t/MW-313.test @@ -0,0 +1,50 @@ +# +# MW-313 Enforce wsrep_max_ws_rows also when binlog is enabled +# + +--source include/galera_cluster.inc +--source include/have_binlog_format_row.inc + +# No error expected for SELECT and SHOW + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; + +SET GLOBAL wsrep_max_ws_rows = 2; + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +SELECT * FROM t1 GROUP BY f1; +SELECT * FROM t1 GROUP BY f1; + +--error 0 +SELECT * FROM t1 GROUP BY f1; + +--disable_result_log +--error 0 +SHOW STATUS LIKE '%wsrep%'; +--enable_result_log + +# Error expected for DML + +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 SELECT * FROM t1; + +START TRANSACTION; +INSERT INTO t1 (f1) VALUES (1); + +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f1) VALUES (2),(3),(4); + +ROLLBACK; +START TRANSACTION; +--error ER_ERROR_DURING_COMMIT +DELETE FROM t1; + +DROP TABLE t1; +SET GLOBAL wsrep_max_ws_rows = 0; From f369942d90ed00be6a05c36efc86e2739161e587 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Thu, 23 Mar 2017 15:00:14 +0530 Subject: [PATCH 12/52] Galera MTR Tests: stability fixes * remove part of galera_var_cluster_address.test that can not be tested reliably * reduce running time for galera_gcache_recover_manytrx.test * Additional wait_conditions for GAL-401.test Signed-off-by: Sachin Setiya --- mysql-test/include/galera_wait_ready.inc | 2 ++ .../galera/r/galera_many_tables_pk.result | 11 +++--- .../r/galera_var_cluster_address.result | 24 +------------ mysql-test/suite/galera/t/GAL-401.test | 3 ++ .../t/galera_gcache_recover_manytrx.cnf | 1 + .../suite/galera/t/galera_many_tables_pk.test | 25 ++++++-------- .../galera/t/galera_var_cluster_address.test | 34 +------------------ 7 files changed, 25 insertions(+), 75 deletions(-) create mode 100644 mysql-test/include/galera_wait_ready.inc diff --git a/mysql-test/include/galera_wait_ready.inc b/mysql-test/include/galera_wait_ready.inc new file mode 100644 index 00000000000..e20f01fad90 --- /dev/null +++ b/mysql-test/include/galera_wait_ready.inc @@ -0,0 +1,2 @@ +let $wait_condition = SELECT 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready' AND VARIABLE_VALUE = 'ON'; +--source include/wait_condition.inc diff --git a/mysql-test/suite/galera/r/galera_many_tables_pk.result b/mysql-test/suite/galera/r/galera_many_tables_pk.result index d0aa1694e85..37474797d74 100644 --- a/mysql-test/suite/galera/r/galera_many_tables_pk.result +++ b/mysql-test/suite/galera/r/galera_many_tables_pk.result @@ -1,20 +1,21 @@ -SELECT COUNT(*) = 900 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't%'; -COUNT(*) = 900 +SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't%'; +COUNT(*) = 100 1 SET AUTOCOMMIT=OFF; START TRANSACTION; COMMIT; CREATE TABLE sum_table (f1 INTEGER); -SELECT SUM(f1) = 900 FROM sum_table; -SUM(f1) = 900 +SELECT SUM(f1) = 100 FROM sum_table; +SUM(f1) = 100 1 SET AUTOCOMMIT=OFF; START TRANSACTION; SET AUTOCOMMIT=OFF; START TRANSACTION; -UPDATE t900 SET f1 = 3; +UPDATE t100 SET f1 = 3; COMMIT; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +include/diff_servers.inc [servers=1 2] DROP SCHEMA test; CREATE SCHEMA test; diff --git a/mysql-test/suite/galera/r/galera_var_cluster_address.result b/mysql-test/suite/galera/r/galera_var_cluster_address.result index 8c23b660d4f..7c56e22eca2 100644 --- a/mysql-test/suite/galera/r/galera_var_cluster_address.result +++ b/mysql-test/suite/galera/r/galera_var_cluster_address.result @@ -26,28 +26,6 @@ VARIABLE_VALUE = 'Primary' SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 -SET GLOBAL wsrep_cluster_address = 'gcomm://192.0.2.1'; -SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS; -COUNT(*) > 0 -1 -SHOW STATUS LIKE 'wsrep_ready'; -Variable_name Value -wsrep_ready OFF -SHOW STATUS LIKE 'wsrep_cluster_status'; -Variable_name Value -wsrep_cluster_status non-Primary -SHOW STATUS LIKE 'wsrep_local_state'; -Variable_name Value -wsrep_local_state 0 -SHOW STATUS LIKE 'wsrep_local_state_comment'; -Variable_name Value -wsrep_local_state_comment Initialized -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -VARIABLE_VALUE = 'Primary' -1 -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -VARIABLE_VALUE = 2 -1 CALL mtr.add_suppression("Backend not supported: foo"); CALL mtr.add_suppression("Failed to initialize backend using 'foo"); CALL mtr.add_suppression("Failed to open channel 'my_wsrep_cluster' at 'foo"); @@ -59,4 +37,4 @@ CALL mtr.add_suppression("Failed to open backend connection: -110 \\(Connection CALL mtr.add_suppression("gcs connect failed: Connection timed out"); CALL mtr.add_suppression("WSREP: wsrep::connect\\(foo://\\) failed: 7"); CALL mtr.add_suppression("WSREP: wsrep::connect\\(gcomm://192.0.2.1\\) failed: 7"); -# End of test \ No newline at end of file +# End of test diff --git a/mysql-test/suite/galera/t/GAL-401.test b/mysql-test/suite/galera/t/GAL-401.test index b7ee36fb1c8..4b7ec95eb68 100644 --- a/mysql-test/suite/galera/t/GAL-401.test +++ b/mysql-test/suite/galera/t/GAL-401.test @@ -38,6 +38,9 @@ SHOW STATUS LIKE 'wsrep_desync_count'; # Resync node_2, should pass: SET @@global.wsrep_desync = 0; +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--source include/wait_condition.inc + SET SESSION wsrep_sync_wait=7; SHOW CREATE TABLE t1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf index 39af0e94b94..c08551eae84 100644 --- a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf +++ b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf @@ -5,4 +5,5 @@ innodb_log_file_size=110M wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.recover=yes;pc.ignore_sb=true;' [mysqld.2] +innodb_log_file_size=110M wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.recover=yes;pc.ignore_sb=true;' diff --git a/mysql-test/suite/galera/t/galera_many_tables_pk.test b/mysql-test/suite/galera/t/galera_many_tables_pk.test index 520459e3210..551307b123f 100644 --- a/mysql-test/suite/galera/t/galera_many_tables_pk.test +++ b/mysql-test/suite/galera/t/galera_many_tables_pk.test @@ -7,18 +7,12 @@ if (!`SELECT @@open_files_limit >= 1024`){ } # -# This test forces 900 tables with a PK to participate in a single -# transaction. The reason for 900 is that some linux system has by default -# a limit of 1024 open files / process -# - -# -# First, create 900 tables and make sure the DDLs are all propagated +# First, create 100 tables and make sure the DDLs are all propagated # --connection node_1 ---let $count = 900 +--let $count = 100 while ($count) { --disable_query_log @@ -29,7 +23,7 @@ while ($count) } --connection node_2 -SELECT COUNT(*) = 900 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't%'; +SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't%'; # # Second, create a transaction that uses all those tables @@ -39,7 +33,7 @@ SELECT COUNT(*) = 900 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' SET AUTOCOMMIT=OFF; START TRANSACTION; ---let $count = 900 +--let $count = 100 while ($count) { --disable_query_log @@ -58,7 +52,7 @@ COMMIT; --connection node_2 CREATE TABLE sum_table (f1 INTEGER); ---let $count = 900 +--let $count = 100 while ($count) { --disable_query_log @@ -68,7 +62,7 @@ while ($count) --dec $count } -SELECT SUM(f1) = 900 FROM sum_table; +SELECT SUM(f1) = 100 FROM sum_table; # # Fourth, create a deadlock @@ -78,7 +72,7 @@ SELECT SUM(f1) = 900 FROM sum_table; SET AUTOCOMMIT=OFF; START TRANSACTION; ---let $count = 900 +--let $count = 100 while ($count) { --disable_query_log @@ -91,7 +85,7 @@ while ($count) --connection node_2 SET AUTOCOMMIT=OFF; START TRANSACTION; -UPDATE t900 SET f1 = 3; +UPDATE t100 SET f1 = 3; --connection node_1 COMMIT; @@ -100,5 +94,8 @@ COMMIT; --error ER_LOCK_DEADLOCK COMMIT; +--let $diff_servers = 1 2 +--source include/diff_servers.inc + DROP SCHEMA test; CREATE SCHEMA test; diff --git a/mysql-test/suite/galera/t/galera_var_cluster_address.test b/mysql-test/suite/galera/t/galera_var_cluster_address.test index e5428fb9c6c..0f857eb1aac 100644 --- a/mysql-test/suite/galera/t/galera_var_cluster_address.test +++ b/mysql-test/suite/galera/t/galera_var_cluster_address.test @@ -58,39 +58,6 @@ SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VA SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -# -# Set to invalid host -# - ---connection node_2 -SET GLOBAL wsrep_cluster_address = 'gcomm://192.0.2.1'; - ---error 0 -SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS; - -# Must return 'OFF' -SHOW STATUS LIKE 'wsrep_ready'; - -# Must return 'Non-primary' -SHOW STATUS LIKE 'wsrep_cluster_status'; - -# Must return 0 = 'Initialized' -SHOW STATUS LIKE 'wsrep_local_state'; -SHOW STATUS LIKE 'wsrep_local_state_comment'; - -# -# Reset everything as it was -# - ---connection node_2 ---disable_query_log ---eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_node2'; ---enable_query_log - ---connection node_1 -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; - --connection node_2 CALL mtr.add_suppression("Backend not supported: foo"); CALL mtr.add_suppression("Failed to initialize backend using 'foo"); @@ -109,3 +76,4 @@ CALL mtr.add_suppression("WSREP: wsrep::connect\\(gcomm://192.0.2.1\\) failed: 7 --source include/galera_end.inc --echo # End of test + From 59dcf2a5d55207435d3c826e07ad59b72ff0e1f5 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Sat, 5 Nov 2016 09:15:14 -0700 Subject: [PATCH 13/52] Galera MTR Tests: stability fix for galera#414.test --- mysql-test/suite/galera/t/galera#414.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mysql-test/suite/galera/t/galera#414.test b/mysql-test/suite/galera/t/galera#414.test index 0ee6dcac700..dccb28e4054 100644 --- a/mysql-test/suite/galera/t/galera#414.test +++ b/mysql-test/suite/galera/t/galera#414.test @@ -24,10 +24,14 @@ SET SESSION wsrep_on = OFF; SET SESSION wsrep_on = ON; --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc --connection node_1 CALL mtr.add_suppression("Failed to set packet size"); --connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc CALL mtr.add_suppression("Failed to set packet size"); From 8aa5356d86043e9e451a7942a6519580c7b3ebc5 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Tue, 8 Nov 2016 15:19:37 +0200 Subject: [PATCH 14/52] Bump WSREP_PATCH_VERSION to 18 --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index 488061e4951..c153e4d3aea 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -26,7 +26,7 @@ ENDIF() OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default}) # Set the patch version -SET(WSREP_PATCH_VERSION "17") +SET(WSREP_PATCH_VERSION "18") # Obtain wsrep API version FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/wsrep_api.h" WSREP_API_VERSION From 70ae1dbac074161d8f09d66b344d091b8c79ef94 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Thu, 23 Mar 2017 15:01:57 +0530 Subject: [PATCH 15/52] Galera MTR tests: Make the mysqlhotcopy tests pass on Ubuntu 16.04 Signed-off-by: Sachin Setiya --- mysql-test/include/mysqlhotcopy.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/include/mysqlhotcopy.inc b/mysql-test/include/mysqlhotcopy.inc index f775d782b28..2fc14d599d9 100644 --- a/mysql-test/include/mysqlhotcopy.inc +++ b/mysql-test/include/mysqlhotcopy.inc @@ -109,7 +109,7 @@ DROP DATABASE hotcopy_save; --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --list_files $MYSQLD_DATADIR/hotcopy_save --replace_result $MASTER_MYSOCK MASTER_MYSOCK ---error 1 +--error 1,9,11,110,2304,255 --exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save --replace_result $MASTER_MYSOCK MASTER_MYSOCK --exec $MYSQLHOTCOPY --quiet --allowold -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save From 836727c9714d05a5756d48c1c7a074a76889c911 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Mon, 21 Nov 2016 10:38:20 +0200 Subject: [PATCH 16/52] refs: MW-319 * silenced the WSREP_ERROR, this fires for all replication filtered DDL, and is false positive --- sql/wsrep_hton.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 8c1394b77e0..7e62e820dcd 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -322,7 +322,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) DBUG_ENTER("wsrep_run_wsrep_commit"); if (thd->get_stmt_da()->is_error()) { - WSREP_ERROR("commit issue, error: %d %s", + WSREP_DEBUG("commit issue, error: %d %s", thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message()); } From cdd1dc829be671b5d866d00841179c9dae10358f Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Thu, 23 Mar 2017 15:46:11 +0530 Subject: [PATCH 17/52] MW-28, codership/mysql-wsrep#28 Fix sync_thread_levels debug assert Introduced a new wsrep_trx_print_locking() which may be called under lock_sys->mutex if the trx has locks. Signed-off-by: Sachin Setiya --- storage/innobase/include/trx0trx.h | 17 +++++ storage/innobase/lock/lock0lock.cc | 8 +-- storage/innobase/trx/trx0trx.cc | 112 +++++++++++++++++++++++++++++ storage/xtradb/include/trx0trx.h | 17 +++++ storage/xtradb/lock/lock0lock.cc | 8 +-- storage/xtradb/trx/trx0trx.cc | 112 +++++++++++++++++++++++++++++ 6 files changed, 262 insertions(+), 12 deletions(-) diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 5936fa90e84..7848cb06955 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -334,6 +334,23 @@ trx_print_latched( or 0 to use the default max length */ MY_ATTRIBUTE((nonnull)); +#ifdef WITH_WSREP +/**********************************************************************//** +Prints info about a transaction. +Transaction information may be retrieved without having trx_sys->mutex acquired +so it may not be completely accurate. The caller must own lock_sys->mutex +and the trx must have some locks to make sure that it does not escape +without locking lock_sys->mutex. */ +UNIV_INTERN +void +wsrep_trx_print_locking( +/*==============*/ + FILE* f, /*!< in: output stream */ + const trx_t* trx, /*!< in: transaction */ + ulint max_query_len) /*!< in: max query length to print, + or 0 to use the default max length */ + MY_ATTRIBUTE((nonnull)); +#endif /* WITH_WSREP */ /**********************************************************************//** Prints info about a transaction. Acquires and releases lock_sys->mutex and trx_sys->mutex. */ diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 4812dc9ae91..a951eff4203 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1752,7 +1752,6 @@ wsrep_kill_victim( is in the queue*/ } else if (lock->trx != trx) { if (wsrep_log_conflicts) { - mutex_enter(&trx_sys->mutex); if (bf_this) { fputs("\n*** Priority TRANSACTION:\n", stderr); @@ -1761,7 +1760,7 @@ wsrep_kill_victim( stderr); } - trx_print_latched(stderr, trx, 3000); + wsrep_trx_print_locking(stderr, trx, 3000); if (bf_other) { fputs("\n*** Priority TRANSACTION:\n", @@ -1770,10 +1769,7 @@ wsrep_kill_victim( fputs("\n*** Victim TRANSACTION:\n", stderr); } - - trx_print_latched(stderr, lock->trx, 3000); - - mutex_exit(&trx_sys->mutex); + wsrep_trx_print_locking(stderr, lock->trx, 3000); fputs("*** WAITING FOR THIS LOCK TO BE GRANTED:\n", stderr); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 318f1e284ec..17a8b296f7a 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1885,6 +1885,118 @@ trx_print_latched( mem_heap_get_size(trx->lock.lock_heap)); } +#ifdef WITH_WSREP +/**********************************************************************//** +Prints info about a transaction. +Transaction information may be retrieved without having trx_sys->mutex acquired +so it may not be completely accurate. The caller must own lock_sys->mutex +and the trx must have some locks to make sure that it does not escape +without locking lock_sys->mutex. */ +UNIV_INTERN +void +wsrep_trx_print_locking( +/*==========*/ + FILE* f, + /*!< in: output stream */ + const trx_t* trx, + /*!< in: transaction */ + ulint max_query_len) + /*!< in: max query length to print, + or 0 to use the default max length */ +{ + ibool newline; + const char* op_info; + + ut_ad(lock_mutex_own()); + ut_ad(trx->lock.trx_locks.count > 0); + + fprintf(f, "TRANSACTION " TRX_ID_FMT, trx->id); + + /* trx->state may change since trx_sys->mutex is not required */ + switch (trx->state) { + case TRX_STATE_NOT_STARTED: + fputs(", not started", f); + goto state_ok; + case TRX_STATE_ACTIVE: + fprintf(f, ", ACTIVE %lu sec", + (ulong) difftime(time(NULL), trx->start_time)); + goto state_ok; + case TRX_STATE_PREPARED: + fprintf(f, ", ACTIVE (PREPARED) %lu sec", + (ulong) difftime(time(NULL), trx->start_time)); + goto state_ok; + case TRX_STATE_COMMITTED_IN_MEMORY: + fputs(", COMMITTED IN MEMORY", f); + goto state_ok; + } + fprintf(f, ", state %lu", (ulong) trx->state); + ut_ad(0); +state_ok: + + /* prevent a race condition */ + op_info = trx->op_info; + + if (*op_info) { + putc(' ', f); + fputs(op_info, f); + } + + if (trx->is_recovered) { + fputs(" recovered trx", f); + } + + if (trx->declared_to_be_inside_innodb) { + fprintf(f, ", thread declared inside InnoDB %lu", + (ulong) trx->n_tickets_to_enter_innodb); + } + + putc('\n', f); + + if (trx->n_mysql_tables_in_use > 0 || trx->mysql_n_tables_locked > 0) { + fprintf(f, "mysql tables in use %lu, locked %lu\n", + (ulong) trx->n_mysql_tables_in_use, + (ulong) trx->mysql_n_tables_locked); + } + + newline = TRUE; + + /* trx->lock.que_state of an ACTIVE transaction may change + while we are not holding trx->mutex. We perform a dirty read + for performance reasons. */ + + switch (trx->lock.que_state) { + case TRX_QUE_RUNNING: + newline = FALSE; break; + case TRX_QUE_LOCK_WAIT: + fputs("LOCK WAIT ", f); break; + case TRX_QUE_ROLLING_BACK: + fputs("ROLLING BACK ", f); break; + case TRX_QUE_COMMITTING: + fputs("COMMITTING ", f); break; + default: + fprintf(f, "que state %lu ", (ulong) trx->lock.que_state); + } + + if (trx->has_search_latch) { + newline = TRUE; + fputs(", holds adaptive hash latch", f); + } + + if (trx->undo_no != 0) { + newline = TRUE; + fprintf(f, ", undo log entries " TRX_ID_FMT, trx->undo_no); + } + + if (newline) { + putc('\n', f); + } + + if (trx->mysql_thd != NULL) { + innobase_mysql_print_thd( + f, trx->mysql_thd, static_cast(max_query_len)); + } +} +#endif /* WITH_WSREP */ /**********************************************************************//** Prints info about a transaction. Acquires and releases lock_sys->mutex and trx_sys->mutex. */ diff --git a/storage/xtradb/include/trx0trx.h b/storage/xtradb/include/trx0trx.h index 9e2064c3dc2..b5fa3930bbb 100644 --- a/storage/xtradb/include/trx0trx.h +++ b/storage/xtradb/include/trx0trx.h @@ -348,6 +348,23 @@ trx_print_latched( or 0 to use the default max length */ MY_ATTRIBUTE((nonnull)); +#ifdef WITH_WSREP +/**********************************************************************//** +Prints info about a transaction. +Transaction information may be retrieved without having trx_sys->mutex acquired +so it may not be completely accurate. The caller must own lock_sys->mutex +and the trx must have some locks to make sure that it does not escape +without locking lock_sys->mutex. */ +UNIV_INTERN +void +wsrep_trx_print_locking( +/*==============*/ + FILE* f, /*!< in: output stream */ + const trx_t* trx, /*!< in: transaction */ + ulint max_query_len) /*!< in: max query length to print, + or 0 to use the default max length */ + MY_ATTRIBUTE((nonnull)); +#endif /* WITH_WSREP */ /**********************************************************************//** Prints info about a transaction. Acquires and releases lock_sys->mutex and trx_sys->mutex. */ diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 0d555ed2dd7..717fbf02536 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -1762,7 +1762,6 @@ wsrep_kill_victim( is in the queue*/ } else if (lock->trx != trx) { if (wsrep_log_conflicts) { - mutex_enter(&trx_sys->mutex); if (bf_this) { fputs("\n*** Priority TRANSACTION:\n", stderr); @@ -1771,7 +1770,7 @@ wsrep_kill_victim( stderr); } - trx_print_latched(stderr, trx, 3000); + wsrep_trx_print_locking(stderr, trx, 3000); if (bf_other) { fputs("\n*** Priority TRANSACTION:\n", @@ -1780,10 +1779,7 @@ wsrep_kill_victim( fputs("\n*** Victim TRANSACTION:\n", stderr); } - - trx_print_latched(stderr, lock->trx, 3000); - - mutex_exit(&trx_sys->mutex); + wsrep_trx_print_locking(stderr, lock->trx, 3000); fputs("*** WAITING FOR THIS LOCK TO BE GRANTED:\n", stderr); diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc index 439897a5b96..92d7525ea84 100644 --- a/storage/xtradb/trx/trx0trx.cc +++ b/storage/xtradb/trx/trx0trx.cc @@ -2161,6 +2161,118 @@ trx_print_latched( mem_heap_get_size(trx->lock.lock_heap)); } +#ifdef WITH_WSREP +/**********************************************************************//** +Prints info about a transaction. +Transaction information may be retrieved without having trx_sys->mutex acquired +so it may not be completely accurate. The caller must own lock_sys->mutex +and the trx must have some locks to make sure that it does not escape +without locking lock_sys->mutex. */ +UNIV_INTERN +void +wsrep_trx_print_locking( +/*==========*/ + FILE* f, + /*!< in: output stream */ + const trx_t* trx, + /*!< in: transaction */ + ulint max_query_len) + /*!< in: max query length to print, + or 0 to use the default max length */ +{ + ibool newline; + const char* op_info; + + ut_ad(lock_mutex_own()); + ut_ad(trx->lock.trx_locks.count > 0); + + fprintf(f, "TRANSACTION " TRX_ID_FMT, trx->id); + + /* trx->state may change since trx_sys->mutex is not required */ + switch (trx->state) { + case TRX_STATE_NOT_STARTED: + fputs(", not started", f); + goto state_ok; + case TRX_STATE_ACTIVE: + fprintf(f, ", ACTIVE %lu sec", + (ulong) difftime(time(NULL), trx->start_time)); + goto state_ok; + case TRX_STATE_PREPARED: + fprintf(f, ", ACTIVE (PREPARED) %lu sec", + (ulong) difftime(time(NULL), trx->start_time)); + goto state_ok; + case TRX_STATE_COMMITTED_IN_MEMORY: + fputs(", COMMITTED IN MEMORY", f); + goto state_ok; + } + fprintf(f, ", state %lu", (ulong) trx->state); + ut_ad(0); +state_ok: + + /* prevent a race condition */ + op_info = trx->op_info; + + if (*op_info) { + putc(' ', f); + fputs(op_info, f); + } + + if (trx->is_recovered) { + fputs(" recovered trx", f); + } + + if (trx->declared_to_be_inside_innodb) { + fprintf(f, ", thread declared inside InnoDB %lu", + (ulong) trx->n_tickets_to_enter_innodb); + } + + putc('\n', f); + + if (trx->n_mysql_tables_in_use > 0 || trx->mysql_n_tables_locked > 0) { + fprintf(f, "mysql tables in use %lu, locked %lu\n", + (ulong) trx->n_mysql_tables_in_use, + (ulong) trx->mysql_n_tables_locked); + } + + newline = TRUE; + + /* trx->lock.que_state of an ACTIVE transaction may change + while we are not holding trx->mutex. We perform a dirty read + for performance reasons. */ + + switch (trx->lock.que_state) { + case TRX_QUE_RUNNING: + newline = FALSE; break; + case TRX_QUE_LOCK_WAIT: + fputs("LOCK WAIT ", f); break; + case TRX_QUE_ROLLING_BACK: + fputs("ROLLING BACK ", f); break; + case TRX_QUE_COMMITTING: + fputs("COMMITTING ", f); break; + default: + fprintf(f, "que state %lu ", (ulong) trx->lock.que_state); + } + + if (trx->has_search_latch) { + newline = TRUE; + fputs(", holds adaptive hash latch", f); + } + + if (trx->undo_no != 0) { + newline = TRUE; + fprintf(f, ", undo log entries " TRX_ID_FMT, trx->undo_no); + } + + if (newline) { + putc('\n', f); + } + + if (trx->mysql_thd != NULL) { + innobase_mysql_print_thd( + f, trx->mysql_thd, static_cast(max_query_len)); + } +} +#endif /* WITH_WSREP */ /**********************************************************************//** Prints info about a transaction. Acquires and releases lock_sys->mutex and trx_sys->mutex. */ From 298daccb1046f8cf6f98727b037ffe298c6b1921 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 23 Nov 2016 02:55:36 -0800 Subject: [PATCH 18/52] Galera MTR Test: Test for MW-28 : Assertion with --wsrep-log-conflicts --- .../galera/r/galera_wsrep_log_conficts.result | 18 ++++++ .../t/galera_wsrep_log_conficts-master.opt | 1 + .../galera/t/galera_wsrep_log_conficts.test | 55 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera_wsrep_log_conficts.result create mode 100644 mysql-test/suite/galera/t/galera_wsrep_log_conficts-master.opt create mode 100644 mysql-test/suite/galera/t/galera_wsrep_log_conficts.test diff --git a/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result b/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result new file mode 100644 index 00000000000..b535c6477b7 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result @@ -0,0 +1,18 @@ +CREATE TABLE t1 ( +f1 VARCHAR(255) PRIMARY KEY +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +INSERT INTO t1 VALUES ('abc'); +SELECT f1 = 'abc' FROM t1; +f1 = 'abc' +1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'klm'; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'xyz'; +COMMIT; +COMMIT; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +include/assert_grep.inc [cluster conflict due to high priority abort for threads] +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_wsrep_log_conficts-master.opt b/mysql-test/suite/galera/t/galera_wsrep_log_conficts-master.opt new file mode 100644 index 00000000000..930c483bd64 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wsrep_log_conficts-master.opt @@ -0,0 +1 @@ +--wsrep_log_conflicts=ON diff --git a/mysql-test/suite/galera/t/galera_wsrep_log_conficts.test b/mysql-test/suite/galera/t/galera_wsrep_log_conficts.test new file mode 100644 index 00000000000..3af08cbf637 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wsrep_log_conficts.test @@ -0,0 +1,55 @@ +# +# Test --wsrep_log_conflicts=ON +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 ( + f1 VARCHAR(255) PRIMARY KEY +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO t1 VALUES ('abc'); + +--connection node_2 +SELECT f1 = 'abc' FROM t1; + +# +# Provoke a conflict +# + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'klm'; + +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'xyz'; + +--connection node_1 +COMMIT; + +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--connection node_2a +--let $wait_condition = SELECT f1 = 'klm' FROM t1; +--source include/wait_condition.inc + +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; + +# +# We can not really check the log output very much because it is quite variable +# + +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err +--let $assert_only_after = CURRENT_TEST + +--let $assert_text = cluster conflict due to high priority abort for threads +--let $assert_select = cluster conflict due to high priority abort for threads +--let $assert_match = cluster conflict due to high priority abort for threads +--source include/assert_grep.inc + +DROP TABLE t1; From 770553e1857eeb8552caf30b930e4233c060de8a Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Fri, 25 Nov 2016 16:56:57 -0200 Subject: [PATCH 19/52] GAL-480 MTR test --- mysql-test/suite/galera/r/GAL-480.result | 39 ++++++++++++++++++++ mysql-test/suite/galera/t/GAL-480.test | 46 ++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 mysql-test/suite/galera/r/GAL-480.result create mode 100644 mysql-test/suite/galera/t/GAL-480.test diff --git a/mysql-test/suite/galera/r/GAL-480.result b/mysql-test/suite/galera/r/GAL-480.result new file mode 100644 index 00000000000..b762e07423e --- /dev/null +++ b/mysql-test/suite/galera/r/GAL-480.result @@ -0,0 +1,39 @@ +CREATE TABLE t1 (f1 CHAR(10), f0 integer) ENGINE=InnoDB; +FLUSH TABLE t1 FOR EXPORT; +UNLOCK TABLES; +ALTER TABLE t1 DROP COLUMN f1; +SET SESSION wsrep_osu_method='RSU'; +ALTER TABLE t1 ADD COLUMN f1 CHAR(10); +ALTER TABLE t1 DROP COLUMN f1; +ALTER TABLE t1 ADD COLUMN f2 CHAR(10); +ALTER TABLE t1 DROP COLUMN f2; +ALTER TABLE t1 ADD COLUMN f3 CHAR(10); +ALTER TABLE t1 DROP COLUMN f3; +ALTER TABLE t1 ADD COLUMN f4 CHAR(10); +ALTER TABLE t1 DROP COLUMN f4; +ALTER TABLE t1 ADD COLUMN f5 CHAR(10); +ALTER TABLE t1 DROP COLUMN f5; +ALTER TABLE t1 ADD COLUMN f6 CHAR(10); +ALTER TABLE t1 DROP COLUMN f6; +ALTER TABLE t1 ADD COLUMN f7 CHAR(10); +ALTER TABLE t1 DROP COLUMN f7; +ALTER TABLE t1 ADD COLUMN f8 CHAR(10); +ALTER TABLE t1 DROP COLUMN f8; +ALTER TABLE t1 ADD COLUMN f9 CHAR(10); +ALTER TABLE t1 DROP COLUMN f9; +ALTER TABLE t1 ADD COLUMN f10 CHAR(10); +ALTER TABLE t1 DROP COLUMN f10; +ALTER TABLE t1 ADD COLUMN f11 CHAR(10); +ALTER TABLE t1 DROP COLUMN f11; +ALTER TABLE t1 ADD COLUMN f12 CHAR(10); +ALTER TABLE t1 DROP COLUMN f12; +ALTER TABLE t1 ADD COLUMN f13 CHAR(10); +ALTER TABLE t1 DROP COLUMN f13; +ALTER TABLE t1 ADD COLUMN f14 CHAR(10); +ALTER TABLE t1 DROP COLUMN f14; +ALTER TABLE t1 ADD COLUMN f15 CHAR(10); +ALTER TABLE t1 DROP COLUMN f15; +ALTER TABLE t1 ADD COLUMN f16 CHAR(10); +ALTER TABLE t1 DROP COLUMN f16; +SET SESSION wsrep_osu_method='TOI'; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/GAL-480.test b/mysql-test/suite/galera/t/GAL-480.test new file mode 100644 index 00000000000..c2b34f2a935 --- /dev/null +++ b/mysql-test/suite/galera/t/GAL-480.test @@ -0,0 +1,46 @@ +--source include/galera_cluster.inc + +--connection node_1 +CREATE TABLE t1 (f1 CHAR(10), f0 integer) ENGINE=InnoDB; + +FLUSH TABLE t1 FOR EXPORT; +UNLOCK TABLES; + +ALTER TABLE t1 DROP COLUMN f1; + +SET SESSION wsrep_osu_method='RSU'; +ALTER TABLE t1 ADD COLUMN f1 CHAR(10); +ALTER TABLE t1 DROP COLUMN f1; +ALTER TABLE t1 ADD COLUMN f2 CHAR(10); +ALTER TABLE t1 DROP COLUMN f2; +ALTER TABLE t1 ADD COLUMN f3 CHAR(10); +ALTER TABLE t1 DROP COLUMN f3; +ALTER TABLE t1 ADD COLUMN f4 CHAR(10); +ALTER TABLE t1 DROP COLUMN f4; +ALTER TABLE t1 ADD COLUMN f5 CHAR(10); +ALTER TABLE t1 DROP COLUMN f5; +ALTER TABLE t1 ADD COLUMN f6 CHAR(10); +ALTER TABLE t1 DROP COLUMN f6; +ALTER TABLE t1 ADD COLUMN f7 CHAR(10); +ALTER TABLE t1 DROP COLUMN f7; +ALTER TABLE t1 ADD COLUMN f8 CHAR(10); +ALTER TABLE t1 DROP COLUMN f8; +ALTER TABLE t1 ADD COLUMN f9 CHAR(10); +ALTER TABLE t1 DROP COLUMN f9; +ALTER TABLE t1 ADD COLUMN f10 CHAR(10); +ALTER TABLE t1 DROP COLUMN f10; +ALTER TABLE t1 ADD COLUMN f11 CHAR(10); +ALTER TABLE t1 DROP COLUMN f11; +ALTER TABLE t1 ADD COLUMN f12 CHAR(10); +ALTER TABLE t1 DROP COLUMN f12; +ALTER TABLE t1 ADD COLUMN f13 CHAR(10); +ALTER TABLE t1 DROP COLUMN f13; +ALTER TABLE t1 ADD COLUMN f14 CHAR(10); +ALTER TABLE t1 DROP COLUMN f14; +ALTER TABLE t1 ADD COLUMN f15 CHAR(10); +ALTER TABLE t1 DROP COLUMN f15; +ALTER TABLE t1 ADD COLUMN f16 CHAR(10); +ALTER TABLE t1 DROP COLUMN f16; + +SET SESSION wsrep_osu_method='TOI'; +DROP TABLE t1; From ff7426290ce0d46f25b0d510171f11c08e7f11a7 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Thu, 23 Mar 2017 16:52:55 +0530 Subject: [PATCH 20/52] MW-329 Fix incorrect affected rows count after replay Fixes wsrep_replay_transaction so that it preserves affected rows, last insert id, and message from diagnostics area. --- sql/wsrep_mysqld.h | 1 + sql/wsrep_thd.cc | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 0155d3684b2..f02a3cd72f3 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -51,6 +51,7 @@ struct wsrep_thd_shadow { char *db; size_t db_length; my_hrtime_t user_time; + longlong row_count_func; }; // Global wsrep parameters diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index cf69a4d2d12..c55b79a999f 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -165,6 +165,7 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow) shadow->db = thd->db; shadow->db_length = thd->db_length; shadow->user_time = thd->user_time; + shadow->row_count_func= thd->get_row_count_func(); thd->reset_db(NULL, 0); } @@ -185,6 +186,7 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow) thd->wsrep_rgi->cleanup_after_session(); delete thd->wsrep_rgi; thd->wsrep_rgi = NULL; + thd->set_row_count_func(shadow->row_count_func); } void wsrep_replay_transaction(THD *thd) @@ -199,12 +201,31 @@ void wsrep_replay_transaction(THD *thd) WSREP_ERROR("replay issue, thd has reported status already"); } + /* PS reprepare observer should have been removed already. open_table() will fail if we have dangling observer here. */ DBUG_ASSERT(thd->m_reprepare_observer == NULL); + struct da_shadow + { + enum Diagnostics_area::enum_diagnostics_status status; + ulonglong affected_rows; + ulonglong last_insert_id; + char message[MYSQL_ERRMSG_SIZE]; + }; + struct da_shadow da_status; + da_status.status= thd->get_stmt_da()->status(); + if (da_status.status == Diagnostics_area::DA_OK) + { + da_status.affected_rows= thd->get_stmt_da()->affected_rows(); + da_status.last_insert_id= thd->get_stmt_da()->last_insert_id(); + strmake(da_status.message, + thd->get_stmt_da()->message(), + sizeof(da_status.message)-1); + } + thd->get_stmt_da()->reset_diagnostics_area(); thd->wsrep_conflict_state= REPLAYING; @@ -271,7 +292,17 @@ void wsrep_replay_transaction(THD *thd) } else { - my_ok(thd); + if (da_status.status == Diagnostics_area::DA_OK) + { + my_ok(thd, + da_status.affected_rows, + da_status.last_insert_id, + da_status.message); + } + else + { + my_ok(thd); + } } break; case WSREP_TRX_FAIL: From 59f3285f35bf02a18a19842a09dcca89562a0bc3 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Thu, 8 Dec 2016 00:17:28 -0800 Subject: [PATCH 21/52] Galera MTR Tests: Test for MW-329 Fix incorrect affected rows count after replay --- mysql-test/suite/galera/r/MW-329.result | 80 +++++++++++++++++++++++++ mysql-test/suite/galera/t/MW-329.test | 61 +++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-329.result create mode 100644 mysql-test/suite/galera/t/MW-329.test diff --git a/mysql-test/suite/galera/r/MW-329.result b/mysql-test/suite/galera/r/MW-329.result new file mode 100644 index 00000000000..c782bf38f48 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-329.result @@ -0,0 +1,80 @@ +CREATE TABLE t1 (f1 INTEGER, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB; +INSERT INTO t1 (f1) VALUES (1),(65535); +FLUSH STATUS; +SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'; +VARIABLE_VALUE = 0 +1 +CREATE PROCEDURE proc_insert () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +INSERT INTO t1 (f1) VALUES (FLOOR( 1 + RAND( ) * 65535 )); +END WHILE; +END| +CALL proc_insert();; +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT ROW_COUNT() > 0; +ROW_COUNT() > 0 +1 +SELECT FOUND_ROWS() > 0; +FOUND_ROWS() > 0 +1 +SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'; +VARIABLE_VALUE > 0 +1 +DROP PROCEDURE proc_insert; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-329.test b/mysql-test/suite/galera/t/MW-329.test new file mode 100644 index 00000000000..d22eb4d6a79 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-329.test @@ -0,0 +1,61 @@ +# +# #MW-329 Fix incorrect affected rows count after replay +# + +--source include/galera_cluster.inc + +CREATE TABLE t1 (f1 INTEGER, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB; + +# We start with a populated table +INSERT INTO t1 (f1) VALUES (1),(65535); + +# Clear the wsrep_local_replays counter + +FLUSH STATUS; +SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'; + +# +# Run concurrent INSERTs +# + +DELIMITER |; +CREATE PROCEDURE proc_insert () +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SET SESSION wsrep_sync_wait = 0; + WHILE 1 DO + INSERT INTO t1 (f1) VALUES (FLOOR( 1 + RAND( ) * 65535 )); + END WHILE; +END| +DELIMITER ;| + +--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1b +--send CALL proc_insert(); + +# +# Run concurrent UPDATEs. We expect that each UPDATE will report that +# some rows were matched and updated +# + +--connection node_2 +--let $count = 10 +while ($count) +{ + --let $signature = `SELECT LEFT(MD5(RAND()), 10)` + --disable_query_log + --eval UPDATE t1 SET f2 = '$signature' + --enable_query_log + SELECT ROW_COUNT() > 0; + SELECT FOUND_ROWS() > 0; + --dec $count +} + +# +# Confirm that some transaction replays occurred +# + +SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'; + +DROP PROCEDURE proc_insert; +DROP TABLE t1; From 97a3a07c35e1c4f27d85e956a8fc2e8c639f961f Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Thu, 8 Dec 2016 05:15:31 -0800 Subject: [PATCH 22/52] Galera MTR Tests: Stability fix for MW-329 --- mysql-test/suite/galera/r/MW-329.result | 60 --------------------- mysql-test/suite/galera/t/MW-329-master.opt | 1 + mysql-test/suite/galera/t/MW-329.test | 24 ++++++++- 3 files changed, 23 insertions(+), 62 deletions(-) create mode 100644 mysql-test/suite/galera/t/MW-329-master.opt diff --git a/mysql-test/suite/galera/r/MW-329.result b/mysql-test/suite/galera/r/MW-329.result index c782bf38f48..655d8e9e291 100644 --- a/mysql-test/suite/galera/r/MW-329.result +++ b/mysql-test/suite/galera/r/MW-329.result @@ -13,66 +13,6 @@ INSERT INTO t1 (f1) VALUES (FLOOR( 1 + RAND( ) * 65535 )); END WHILE; END| CALL proc_insert();; -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 -SELECT ROW_COUNT() > 0; -ROW_COUNT() > 0 -1 -SELECT FOUND_ROWS() > 0; -FOUND_ROWS() > 0 -1 SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'; VARIABLE_VALUE > 0 1 diff --git a/mysql-test/suite/galera/t/MW-329-master.opt b/mysql-test/suite/galera/t/MW-329-master.opt new file mode 100644 index 00000000000..6565a6af3c4 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-329-master.opt @@ -0,0 +1 @@ +--wsrep-retry-autocommit=0 diff --git a/mysql-test/suite/galera/t/MW-329.test b/mysql-test/suite/galera/t/MW-329.test index d22eb4d6a79..445f8795dff 100644 --- a/mysql-test/suite/galera/t/MW-329.test +++ b/mysql-test/suite/galera/t/MW-329.test @@ -31,6 +31,7 @@ DELIMITER ;| --connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 --connection node_1b +--let $connection_id = `SELECT CONNECTION_ID()` --send CALL proc_insert(); # @@ -44,10 +45,15 @@ while ($count) { --let $signature = `SELECT LEFT(MD5(RAND()), 10)` --disable_query_log + --error 0,ER_LOCK_DEADLOCK --eval UPDATE t1 SET f2 = '$signature' --enable_query_log - SELECT ROW_COUNT() > 0; - SELECT FOUND_ROWS() > 0; + --let $row_count = `SELECT ROW_COUNT()` + if (`SELECT @@error_count = 0`) { + if (`SELECT $row_count = 0`) { + --die ROW_COUNT() = 0 + } + } --dec $count } @@ -57,5 +63,19 @@ while ($count) SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'; +# +# Terminate the stored procedure +# + +--connection node_1 +--disable_query_log +--eval KILL CONNECTION $connection_id +--enable_query_log + +--connection node_1b +--error 0,2013,1317 +--reap + +--connection node_1 DROP PROCEDURE proc_insert; DROP TABLE t1; From 66916bba2a08df1e307d5333078f7586d02c4bf6 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Fri, 16 Dec 2016 02:30:09 -0800 Subject: [PATCH 23/52] Galera MTR Tests: Tests for MW-328 Fix unnecessary/silent BF aborts --- mysql-test/suite/galera/r/MW-328A.result | 21 ++++++++ mysql-test/suite/galera/r/MW-328B.result | 17 +++++++ mysql-test/suite/galera/r/MW-328C.result | 17 +++++++ mysql-test/suite/galera/r/MW-328D.result | 15 ++++++ mysql-test/suite/galera/r/MW-328E.result | 15 ++++++ mysql-test/suite/galera/t/MW-328-footer.inc | 18 +++++++ mysql-test/suite/galera/t/MW-328-header.inc | 29 +++++++++++ mysql-test/suite/galera/t/MW-328A.test | 55 +++++++++++++++++++++ mysql-test/suite/galera/t/MW-328B.test | 35 +++++++++++++ mysql-test/suite/galera/t/MW-328C.test | 35 +++++++++++++ mysql-test/suite/galera/t/MW-328D.test | 39 +++++++++++++++ mysql-test/suite/galera/t/MW-328E.test | 40 +++++++++++++++ 12 files changed, 336 insertions(+) create mode 100644 mysql-test/suite/galera/r/MW-328A.result create mode 100644 mysql-test/suite/galera/r/MW-328B.result create mode 100644 mysql-test/suite/galera/r/MW-328C.result create mode 100644 mysql-test/suite/galera/r/MW-328D.result create mode 100644 mysql-test/suite/galera/r/MW-328E.result create mode 100644 mysql-test/suite/galera/t/MW-328-footer.inc create mode 100644 mysql-test/suite/galera/t/MW-328-header.inc create mode 100644 mysql-test/suite/galera/t/MW-328A.test create mode 100644 mysql-test/suite/galera/t/MW-328B.test create mode 100644 mysql-test/suite/galera/t/MW-328C.test create mode 100644 mysql-test/suite/galera/t/MW-328D.test create mode 100644 mysql-test/suite/galera/t/MW-328E.test diff --git a/mysql-test/suite/galera/r/MW-328A.result b/mysql-test/suite/galera/r/MW-328A.result new file mode 100644 index 00000000000..daed2469f11 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-328A.result @@ -0,0 +1,21 @@ +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB; +INSERT INTO t1 (f1) VALUES (1); +CREATE TABLE t2 (f1 CHAR(20)) ENGINE=InnoDB; +CREATE PROCEDURE proc_update () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +UPDATE t1 SET f2 = LEFT(MD5(RAND()), 4); +END WHILE; +END| +CALL proc_update();; +SET SESSION wsrep_retry_autocommit = 0; +have_successes +1 +have_deadlocks +1 +Got one of the listed errors +DROP PROCEDURE proc_update; +DROP TABLE t1, t2; +CALL mtr.add_suppression("conflict state 3 after post commit"); diff --git a/mysql-test/suite/galera/r/MW-328B.result b/mysql-test/suite/galera/r/MW-328B.result new file mode 100644 index 00000000000..780988938f6 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-328B.result @@ -0,0 +1,17 @@ +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB; +INSERT INTO t1 (f1) VALUES (1); +CREATE TABLE t2 (f1 CHAR(20)) ENGINE=InnoDB; +CREATE PROCEDURE proc_update () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +UPDATE t1 SET f2 = LEFT(MD5(RAND()), 4); +END WHILE; +END| +CALL proc_update();; +SET SESSION wsrep_retry_autocommit = 0; +Got one of the listed errors +DROP PROCEDURE proc_update; +DROP TABLE t1, t2; +CALL mtr.add_suppression("conflict state 3 after post commit"); diff --git a/mysql-test/suite/galera/r/MW-328C.result b/mysql-test/suite/galera/r/MW-328C.result new file mode 100644 index 00000000000..5cd74f05171 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-328C.result @@ -0,0 +1,17 @@ +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB; +INSERT INTO t1 (f1) VALUES (1); +CREATE TABLE t2 (f1 CHAR(20)) ENGINE=InnoDB; +CREATE PROCEDURE proc_update () +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET SESSION wsrep_sync_wait = 0; +WHILE 1 DO +UPDATE t1 SET f2 = LEFT(MD5(RAND()), 4); +END WHILE; +END| +CALL proc_update();; +SET SESSION wsrep_retry_autocommit = 10000; +Got one of the listed errors +DROP PROCEDURE proc_update; +DROP TABLE t1, t2; +CALL mtr.add_suppression("conflict state 3 after post commit"); diff --git a/mysql-test/suite/galera/r/MW-328D.result b/mysql-test/suite/galera/r/MW-328D.result new file mode 100644 index 00000000000..f6d055def93 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-328D.result @@ -0,0 +1,15 @@ +CREATE TABLE t1 (i INT) ENGINE = InnoDB; +INSERT INTO t1 (i) VALUES(1); +CREATE TABLE t2 (i INT) ENGINE = InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +SELECT * FROM t1 WHERE i = 1 LOCK IN SHARE MODE; +i +1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT IGNORE INTO t2 SELECT * FROM t1 WHERE i = 1 FOR UPDATE;; +DELETE FROM t1 WHERE i = 1; +COMMIT; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +DROP TABLE t1, t2; diff --git a/mysql-test/suite/galera/r/MW-328E.result b/mysql-test/suite/galera/r/MW-328E.result new file mode 100644 index 00000000000..5829559fa4d --- /dev/null +++ b/mysql-test/suite/galera/r/MW-328E.result @@ -0,0 +1,15 @@ +create table t1 (i int primary key, j int) engine=innodb; +create table t2 (i int primary key, j int) engine=innodb; +insert into t1 values (1,0); +insert into t2 values (2,0); +set autocommit=off; +start transaction; +update t1 set j=1 where i=1; +set autocommit=off; +start transaction; +begin; +update t2 set j=1 where i=2; +insert into t1 select * from t2;; +insert into t2 select * from t1; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +DROP TABLE t1, t2; diff --git a/mysql-test/suite/galera/t/MW-328-footer.inc b/mysql-test/suite/galera/t/MW-328-footer.inc new file mode 100644 index 00000000000..5b736df220f --- /dev/null +++ b/mysql-test/suite/galera/t/MW-328-footer.inc @@ -0,0 +1,18 @@ +# +# Cleanup for MW-328 tests +# + +--connection node_1 +--disable_query_log +--eval KILL CONNECTION $sp_connection_id +--enable_query_log + +--connection node_1X +--error 2013,1317 +--reap + +--connection node_1 +DROP PROCEDURE proc_update; +DROP TABLE t1, t2; + +CALL mtr.add_suppression("conflict state 3 after post commit"); diff --git a/mysql-test/suite/galera/t/MW-328-header.inc b/mysql-test/suite/galera/t/MW-328-header.inc new file mode 100644 index 00000000000..f0a6ccaccc6 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-328-header.inc @@ -0,0 +1,29 @@ +# +# Initialization for MW-328 tests +# + +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB; +INSERT INTO t1 (f1) VALUES (1); + +CREATE TABLE t2 (f1 CHAR(20)) ENGINE=InnoDB; + +# +# Have some random updates going on against t1 +# + +DELIMITER |; +CREATE PROCEDURE proc_update () +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SET SESSION wsrep_sync_wait = 0; + WHILE 1 DO + UPDATE t1 SET f2 = LEFT(MD5(RAND()), 4); + END WHILE; +END| + +DELIMITER ;| + +--connect node_1X, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1X +--let $sp_connection_id = `SELECT CONNECTION_ID()` +--send CALL proc_update(); diff --git a/mysql-test/suite/galera/t/MW-328A.test b/mysql-test/suite/galera/t/MW-328A.test new file mode 100644 index 00000000000..836dd088749 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-328A.test @@ -0,0 +1,55 @@ +# +# MW-328 Fix unnecessary/silent BF aborts +# + +# +# Attempt to insert into t2 and check if insert actually inserted rows if +# a success was reported. +# + +--source include/galera_cluster.inc +--source suite/galera/t/MW-328-header.inc + +--connection node_2 +--let $count = 100 +--let $successes = 0 +--let $deadlocks = 0 + +SET SESSION wsrep_retry_autocommit = 0; + +--disable_query_log + +while ($count) +{ + TRUNCATE TABLE t2; + + --error 0,1213 + INSERT IGNORE INTO t2 SELECT f2 FROM t1; + if ($mysql_errno != 1213) { + --inc $successes + if (`SELECT COUNT(*) = 0 FROM t2`) { + --die No rows arrived in table t2 + } + } + + if ($mysql_errno == 1213) { + --inc $deadlocks + + } + + --dec $count +} + +--enable_query_log + +# +# Check that the test produced both deadlocks and successes +# + +--disable_query_log +--eval SELECT $successes > 0 AS have_successes +--eval SELECT $deadlocks > 0 AS have_deadlocks +--enable_query_log + + +--source suite/galera/t/MW-328-footer.inc diff --git a/mysql-test/suite/galera/t/MW-328B.test b/mysql-test/suite/galera/t/MW-328B.test new file mode 100644 index 00000000000..11969dd0b47 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-328B.test @@ -0,0 +1,35 @@ +# +# MW-328 Fix unnecessary/silent BF aborts +# + +# +# Make sure an unrelated SELECT following a BF-aborted query never +# gets the deadlock error +# + +--source include/galera_cluster.inc +--source suite/galera/t/MW-328-header.inc + +--connection node_2 +--let $count = 100 + +SET SESSION wsrep_retry_autocommit = 0; + +--disable_query_log + +while ($count) +{ + --error 0,1213 + INSERT IGNORE INTO t2 SELECT f2 FROM t1; + + --disable_result_log + --error 0 + SELECT 1 FROM DUAL; + --enable_result_log + + --dec $count +} + +--enable_query_log + +--source suite/galera/t/MW-328-footer.inc diff --git a/mysql-test/suite/galera/t/MW-328C.test b/mysql-test/suite/galera/t/MW-328C.test new file mode 100644 index 00000000000..7241dfbdbca --- /dev/null +++ b/mysql-test/suite/galera/t/MW-328C.test @@ -0,0 +1,35 @@ +# +# MW-328 Fix unnecessary/silent BF aborts +# + +# +# Make sure that a high value of wsrep_retry_autocommit +# masks all deadlock errors +# + +--source include/galera_cluster.inc +--source suite/galera/t/MW-328-header.inc + +--connection node_2 +--let $count = 100 + +SET SESSION wsrep_retry_autocommit = 10000; + +--disable_query_log + +while ($count) +{ + --error 0 + INSERT IGNORE INTO t2 SELECT f2 FROM t1; + + --disable_result_log + --error 0 + SELECT 1 FROM DUAL; + --enable_result_log + + --dec $count +} + +--enable_query_log + +--source suite/galera/t/MW-328-footer.inc diff --git a/mysql-test/suite/galera/t/MW-328D.test b/mysql-test/suite/galera/t/MW-328D.test new file mode 100644 index 00000000000..e8a22f22a99 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-328D.test @@ -0,0 +1,39 @@ +# +# MW-328 Fix unnecessary/silent BF aborts +# + +# +# Test that non-Galera deadlock error still behaves as expected +# + +--source include/galera_cluster.inc + +CREATE TABLE t1 (i INT) ENGINE = InnoDB; +INSERT INTO t1 (i) VALUES(1); + +CREATE TABLE t2 (i INT) ENGINE = InnoDB; + +# Create a deadlock situation + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +SELECT * FROM t1 WHERE i = 1 LOCK IN SHARE MODE; + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET AUTOCOMMIT=OFF; +START TRANSACTION; +--send INSERT IGNORE INTO t2 SELECT * FROM t1 WHERE i = 1 FOR UPDATE; + +--connection node_1 +--sleep 2 +DELETE FROM t1 WHERE i = 1; +COMMIT; + +# We expect that ER_LOCK_DEADLOCK will be delivered even though it was a INSERT INGORE statement +--connection node_1a +--error ER_LOCK_DEADLOCK +--reap + +DROP TABLE t1, t2; diff --git a/mysql-test/suite/galera/t/MW-328E.test b/mysql-test/suite/galera/t/MW-328E.test new file mode 100644 index 00000000000..34b17be7b08 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-328E.test @@ -0,0 +1,40 @@ +# +# MW-328 Fix unnecessary/silent BF aborts +# + +# +# Test that non-Galera deadlock error still behaves as expected (case #2) +# + +--source include/galera_cluster.inc + +create table t1 (i int primary key, j int) engine=innodb; +create table t2 (i int primary key, j int) engine=innodb; + +insert into t1 values (1,0); +insert into t2 values (2,0); + +set autocommit=off; +start transaction; +update t1 set j=1 where i=1; + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +set autocommit=off; +start transaction; +begin; +update t2 set j=1 where i=2; + +--connection node_1 +# Hang expected here +--send insert into t1 select * from t2; + +--sleep 2 +--connection node_1a +--error ER_LOCK_DEADLOCK +insert into t2 select * from t1; + +--connection node_1 +--reap + +DROP TABLE t1, t2; From adc151fdafb4a2935eddb8f89057dd7b6e9b1b10 Mon Sep 17 00:00:00 2001 From: Philip Stoev Date: Wed, 25 Jan 2017 09:58:07 +0200 Subject: [PATCH 24/52] Bump WSREP_PATCH_VERSION to 19 --- cmake/wsrep.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index c153e4d3aea..0a1c7dd9697 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -26,7 +26,7 @@ ENDIF() OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default}) # Set the patch version -SET(WSREP_PATCH_VERSION "18") +SET(WSREP_PATCH_VERSION "19") # Obtain wsrep API version FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/wsrep_api.h" WSREP_API_VERSION From 633959525ced3f114d3d2dafa6b5b798ec6b26f1 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Tue, 14 Mar 2017 18:41:38 +0530 Subject: [PATCH 25/52] Fix Some failing tests Signed-off-by: Sachin Setiya --- mysql-test/suite/galera/t/MW-258.test | 1 + mysql-test/suite/galera/t/MW-313.test | 1 + mysql-test/suite/galera/t/MW-328A.test | 1 + mysql-test/suite/galera/t/MW-328B.test | 1 + mysql-test/suite/galera/t/MW-328C.test | 1 + mysql-test/suite/galera/t/MW-328D.test | 1 + mysql-test/suite/galera/t/MW-328E.test | 1 + mysql-test/suite/galera/t/MW-329.test | 1 + mysql-test/suite/galera/t/galera_var_retry_autocommit.test | 1 + 9 files changed, 9 insertions(+) diff --git a/mysql-test/suite/galera/t/MW-258.test b/mysql-test/suite/galera/t/MW-258.test index f5519f8a081..174dd2c02c6 100644 --- a/mysql-test/suite/galera/t/MW-258.test +++ b/mysql-test/suite/galera/t/MW-258.test @@ -34,6 +34,7 @@ UNLOCK TABLES; --connection node_1 --echo value after RSU: +--sleep 3 SHOW STATUS LIKE 'wsrep_desync_count'; SHOW VARIABLES LIKE 'wsrep_desync'; SET GLOBAL wsrep_desync=0; diff --git a/mysql-test/suite/galera/t/MW-313.test b/mysql-test/suite/galera/t/MW-313.test index d697cb2cfcd..92fd835c615 100644 --- a/mysql-test/suite/galera/t/MW-313.test +++ b/mysql-test/suite/galera/t/MW-313.test @@ -3,6 +3,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --source include/have_binlog_format_row.inc # No error expected for SELECT and SHOW diff --git a/mysql-test/suite/galera/t/MW-328A.test b/mysql-test/suite/galera/t/MW-328A.test index 836dd088749..4d6e1ea3625 100644 --- a/mysql-test/suite/galera/t/MW-328A.test +++ b/mysql-test/suite/galera/t/MW-328A.test @@ -8,6 +8,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --source suite/galera/t/MW-328-header.inc --connection node_2 diff --git a/mysql-test/suite/galera/t/MW-328B.test b/mysql-test/suite/galera/t/MW-328B.test index 11969dd0b47..a7b4053ab0c 100644 --- a/mysql-test/suite/galera/t/MW-328B.test +++ b/mysql-test/suite/galera/t/MW-328B.test @@ -8,6 +8,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --source suite/galera/t/MW-328-header.inc --connection node_2 diff --git a/mysql-test/suite/galera/t/MW-328C.test b/mysql-test/suite/galera/t/MW-328C.test index 7241dfbdbca..b681e743ab3 100644 --- a/mysql-test/suite/galera/t/MW-328C.test +++ b/mysql-test/suite/galera/t/MW-328C.test @@ -8,6 +8,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --source suite/galera/t/MW-328-header.inc --connection node_2 diff --git a/mysql-test/suite/galera/t/MW-328D.test b/mysql-test/suite/galera/t/MW-328D.test index e8a22f22a99..d5cffdb8f47 100644 --- a/mysql-test/suite/galera/t/MW-328D.test +++ b/mysql-test/suite/galera/t/MW-328D.test @@ -7,6 +7,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc CREATE TABLE t1 (i INT) ENGINE = InnoDB; INSERT INTO t1 (i) VALUES(1); diff --git a/mysql-test/suite/galera/t/MW-328E.test b/mysql-test/suite/galera/t/MW-328E.test index 34b17be7b08..fd4b0bf9039 100644 --- a/mysql-test/suite/galera/t/MW-328E.test +++ b/mysql-test/suite/galera/t/MW-328E.test @@ -7,6 +7,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc create table t1 (i int primary key, j int) engine=innodb; create table t2 (i int primary key, j int) engine=innodb; diff --git a/mysql-test/suite/galera/t/MW-329.test b/mysql-test/suite/galera/t/MW-329.test index 445f8795dff..acf6763b396 100644 --- a/mysql-test/suite/galera/t/MW-329.test +++ b/mysql-test/suite/galera/t/MW-329.test @@ -3,6 +3,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc CREATE TABLE t1 (f1 INTEGER, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB; diff --git a/mysql-test/suite/galera/t/galera_var_retry_autocommit.test b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test index 6ef647b24e1..bf4da3234c5 100644 --- a/mysql-test/suite/galera/t/galera_var_retry_autocommit.test +++ b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test @@ -4,6 +4,7 @@ # --source include/galera_cluster.inc +--source include/have_innodb.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; From bd2064e8207edd4298e4fcf39c597bad4ecc91ca Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Wed, 5 Apr 2017 16:30:03 +0530 Subject: [PATCH 26/52] MW-313 Enforce wsrep_max_ws_rows also when binlog is enabled Signed-off-by: Sachin Setiya --- mysql-test/suite/wsrep/r/wsrep_rpl.result | 4 ++-- mysql-test/suite/wsrep/t/wsrep_rpl.test | 10 ++-------- sql/log_event.cc | 4 ++++ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/wsrep/r/wsrep_rpl.result b/mysql-test/suite/wsrep/r/wsrep_rpl.result index fd792c215b3..a5db3b28ec0 100644 --- a/mysql-test/suite/wsrep/r/wsrep_rpl.result +++ b/mysql-test/suite/wsrep/r/wsrep_rpl.result @@ -5,12 +5,12 @@ include/master-slave.inc # wsrep_max_ws_rows exceeded. Error_Code 1180 # CREATE TABLE t1(i INT) ENGINE = INNODB; -SET @@GLOBAL.wsrep_max_ws_rows = 1; +SET @@GLOBAL.wsrep_max_ws_rows = 2; INSERT INTO t1 VALUES(1), (2); SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 -SET @@GLOBAL.wsrep_max_ws_rows = 1; +SET @@GLOBAL.wsrep_max_ws_rows = 2; DELETE FROM t1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 diff --git a/mysql-test/suite/wsrep/t/wsrep_rpl.test b/mysql-test/suite/wsrep/t/wsrep_rpl.test index 1cc7214325d..4f34aadc365 100644 --- a/mysql-test/suite/wsrep/t/wsrep_rpl.test +++ b/mysql-test/suite/wsrep/t/wsrep_rpl.test @@ -15,18 +15,13 @@ let $wsrep_max_ws_rows_slave = `SELECT @@GLOBAL.wsrep_max_ws_rows`; connection master; CREATE TABLE t1(i INT) ENGINE = INNODB; -# Setting wsrep_max_ws_rows should have no impact on replication master -# unless its a cluster node. -SET @@GLOBAL.wsrep_max_ws_rows = 1; +SET @@GLOBAL.wsrep_max_ws_rows = 2; INSERT INTO t1 VALUES(1), (2); - sync_slave_with_master; SELECT COUNT(*) = 2 FROM t1; connection slave; -# Setting wsrep_max_ws_rows should have no impact on replication slave -# unless its a cluster node. -SET @@GLOBAL.wsrep_max_ws_rows = 1; +SET @@GLOBAL.wsrep_max_ws_rows = 2; connection master; DELETE FROM t1; @@ -38,7 +33,6 @@ connection master; DROP TABLE t1; sync_slave_with_master; - # Restore wsrep_max_ws_rows on master and slave connection master; eval SET @@GLOBAL.wsrep_max_ws_rows = $wsrep_max_ws_rows_master; diff --git a/sql/log_event.cc b/sql/log_event.cc index 3e2592808b1..be7e7e5c3d8 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -7586,6 +7586,10 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi) Record any GTID in the same transaction, so slave state is transactionally consistent. */ + + /*Set wsrep_affected_rows = 0 */ + thd->wsrep_affected_rows= 0; + if (rgi->gtid_pending) { sub_id= rgi->gtid_sub_id; From 5866c4d0840043e984a6d8ad782f3a25746caa84 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Thu, 23 Mar 2017 17:11:31 +0530 Subject: [PATCH 27/52] Fix test cases Signed-off-by: Sachin Setiya --- mysql-test/include/diff_servers.inc | 67 +++++++++++++++++++++ mysql-test/suite/galera/disabled.def | 4 +- mysql-test/suite/galera/t/galera_roles.test | 2 + 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 mysql-test/include/diff_servers.inc diff --git a/mysql-test/include/diff_servers.inc b/mysql-test/include/diff_servers.inc new file mode 100644 index 00000000000..5ec7efc38b9 --- /dev/null +++ b/mysql-test/include/diff_servers.inc @@ -0,0 +1,67 @@ +# ==== Purpose ==== +# +# Check that two or more servers have identical databases; fail if not. +# +# ==== Usage ==== +# +# --let $diff_servers= 1 2 +# [--let $databases= db1 db2 ...] +# [--let $rpl_debug= 1] +# --source include/diff_servers.inc + +# pretty-print header +--let $_ds_info= servers=$diff_servers +if ($databases != '') +{ + --let $_ds_info= $_ds_info databases=$databases +} +--let $include_filename= diff_servers.inc [$_ds_info] +--source include/begin_include_file.inc + +# get databases +--let $_ds_databases= $diff_database +if ($_ds_databases == '') +{ + --let $_ds_databases= `SELECT GROUP_CONCAT(SCHEMA_NAME SEPARATOR ' ') FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'mtr', 'mysql', 'performance_schema')` +} + +# generate command line +--let $_ds_arg= --defaults-group-suffix=. +--let $_ds_number_pos= `SELECT LOCATE('$_ds_arg', '$MYSQL_DUMP') + LENGTH('$_ds_arg')` +--let $_ds_pre_command= `SELECT SUBSTR('$MYSQL_DUMP', 1, $_ds_number_pos - 1)` +--let $_ds_post_command= `SELECT SUBSTR('$MYSQL_DUMP', $_ds_number_pos + 1)` +--let $_ds_post_command= $_ds_post_command --compact --order-by-primary --skip-extended-insert --no-create-info --databases $_ds_databases +--let $_ds_prev_outfile= + +# iterate over servers +--let $_ds_servers= $diff_servers +while ($_ds_servers != '') +{ + --let $_ds_server_number= `SELECT SUBSTRING_INDEX('$_ds_servers', ' ', 1)` + --let $_ds_servers= `SELECT TRIM(SUBSTRING('$_ds_servers', 1 + LENGTH('_$ds_server_number')))` + --let $_ds_outfile= $MYSQLTEST_VARDIR/tmp/diff_servers_$_ds_server_number + + if ($rpl_debug) + { + --echo generating dump from server '$_ds_server_number' using command '$_ds_pre_command$_ds_server_number $_ds_post_command > $_ds_outfile' + --echo remaining servers: '$_ds_servers' + } + --exec $_ds_pre_command$_ds_server_number $_ds_post_command > $_ds_outfile + + if ($_ds_prev_outfile != '') + { + if ($rpl_debug) + { + --echo diffing files '$_ds_prev_outfile' and '$_ds_outfile' + } + --diff_files $_ds_prev_outfile $_ds_outfile + + --remove_file $_ds_prev_outfile + } + --let $_ds_prev_outfile= $_ds_outfile +} + +--remove_file $_ds_prev_outfile + +--let $include_filename= diff_servers.inc [servers=$_ds_info] +--source include/end_include_file.inc diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index d5016eab156..95455cbda44 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -41,4 +41,6 @@ MW-44 : MDEV-11229 galera_gcs_fc_limit : MDEV-11229 galera_roles : MDEV-11229 galera_lock_table : MDEV-11229 - +GAL-480 : Investigate +galera_fk_no_pk :Investigate +galera_account_management : Investigate diff --git a/mysql-test/suite/galera/t/galera_roles.test b/mysql-test/suite/galera/t/galera_roles.test index 16e417d1fdb..eea35762539 100644 --- a/mysql-test/suite/galera/t/galera_roles.test +++ b/mysql-test/suite/galera/t/galera_roles.test @@ -36,6 +36,7 @@ GRANT SELECT (a) ON test1.t2 TO role1; --connect(foo_node_1,127.0.0.1,foo,,test,$port_1,) --let $port_2= \$NODE_MYPORT_2 +--sleep 1 --connect(foo_node_2,127.0.0.1,foo,,test,$port_2,) --echo @@ -101,6 +102,7 @@ REVOKE EXECUTE ON PROCEDURE test1.pr1 FROM role1; --echo # Connect with foo_node_1 --connection foo_node_1 +--sleep 1 --error ER_PROCACCESS_DENIED_ERROR CALL test1.pr1(); From 2af4659b0593a640a1f5f641dc3e8d76ab35685a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 21 Mar 2017 10:00:02 +0200 Subject: [PATCH 28/52] Fix failure on galera_toi_drop_database test. It is assumed that both insert..select statements take so long that drop database from node2 gets to abort them both but on fast machines it was too small. Increased the size of insert. --- mysql-test/suite/galera/r/galera_toi_drop_database.result | 4 ++-- mysql-test/suite/galera/t/galera_toi_drop_database.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_toi_drop_database.result b/mysql-test/suite/galera/r/galera_toi_drop_database.result index 8f4098419eb..d652a5154be 100644 --- a/mysql-test/suite/galera/r/galera_toi_drop_database.result +++ b/mysql-test/suite/galera/r/galera_toi_drop_database.result @@ -5,10 +5,10 @@ INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; SET SESSION wsrep_retry_autocommit = 0; -INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; +INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;; USE database1; SET SESSION wsrep_retry_autocommit = 0; -INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; +INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;; DROP DATABASE database1;; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ERROR 40001: Deadlock found when trying to get lock; try restarting transaction diff --git a/mysql-test/suite/galera/t/galera_toi_drop_database.test b/mysql-test/suite/galera/t/galera_toi_drop_database.test index 0a37a4010ce..e790a0ba812 100644 --- a/mysql-test/suite/galera/t/galera_toi_drop_database.test +++ b/mysql-test/suite/galera/t/galera_toi_drop_database.test @@ -22,12 +22,12 @@ CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; # Make sure autocommit retrying does not kick in as this will mask the error we expect to get SET SESSION wsrep_retry_autocommit = 0; # Attemp to insert 1M rows ---send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6; --connection node_1a USE database1; SET SESSION wsrep_retry_autocommit = 0; ---send INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +--send INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6; --connection node_2 --sleep 1 From 34d11b344b41e313d5d5d0422967c0a45600597e Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Tue, 21 Mar 2017 14:23:45 +0530 Subject: [PATCH 29/52] Fix galera_admin test Patch credit Jan --- mysql-test/suite/galera/t/galera_admin.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/galera/t/galera_admin.test b/mysql-test/suite/galera/t/galera_admin.test index d62c454bdfa..e3c43256ad5 100644 --- a/mysql-test/suite/galera/t/galera_admin.test +++ b/mysql-test/suite/galera/t/galera_admin.test @@ -56,7 +56,7 @@ ANALYZE TABLE t1, t2; OPTIMIZE TABLE t1, t2; --connection node_2 ---let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed' +--let $wait_condition = SELECT VARIABLE_VALUE >= $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed' --source include/wait_condition.inc @@ -69,7 +69,7 @@ OPTIMIZE TABLE t1, t2; REPAIR TABLE x1, x2; --connection node_2 ---let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed' +--let $wait_condition = SELECT VARIABLE_VALUE >= $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed' --source include/wait_condition.inc From 1ba2242ef3f17c37b1cb8921ae6dee4e982a1e79 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Wed, 22 Mar 2017 09:40:57 +0530 Subject: [PATCH 30/52] MDEV-12319 Test added to disabled.def --- mysql-test/suite/galera/disabled.def | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 95455cbda44..5a481d116ba 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -44,3 +44,14 @@ galera_lock_table : MDEV-11229 GAL-480 : Investigate galera_fk_no_pk :Investigate galera_account_management : Investigate +galera.galera_var_retry_autocommit : MDEV-12319 #Sparodic Faliure +galera.galera_gcs_fc_limit : MDEV-12319 #Sparodic Faliure +galera.galera_toi_ddl_nonconflicting : MDEV-12319 #Sparodic Faliure +galera.mysql-wsrep#198 : MDEV-12319 #Sparodic Faliure +galera.galera_pc_ignore_sb : MDEV-12319 #Sparodic Faliure +galera.MW-329 : MDEV-12319 #Sparodic Faliure +galera.galera_ist_recv_bind : MDEV-12319 #Failed to start mysqld +galera.galera_ist_restart_joiner : MDEV-12319 #Failed to start mysqld +galera.galera_ssl_compression : MDEV-12319 #Failed to start mysqld +galera.galera_wan : MDEV-12319 #Failed to start mysqld +galera.rpl_row_annotate : MDEV-12319 #Failed to start mysqld From d036cc9b2f595cac1453f2a251515c6b9a408521 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Fri, 24 Mar 2017 16:20:59 +0530 Subject: [PATCH 31/52] Fix WSREP_PATCH_VERSION --- mysql-test/suite/sys_vars/r/sysvars_wsrep.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result index 53838366a16..802ee3b1c6d 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result +++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result @@ -367,7 +367,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME WSREP_PATCH_VERSION SESSION_VALUE NULL -GLOBAL_VALUE wsrep_25.16 +GLOBAL_VALUE wsrep_25.19 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL From 969fc61120ea2ae57477e46596f487dbe8c19d98 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Tue, 28 Mar 2017 13:09:28 +0530 Subject: [PATCH 32/52] Fix build on windows Signed-off-by: Sachin Setiya --- sql/log_event.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index be7e7e5c3d8..bae723402e7 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -7586,9 +7586,10 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi) Record any GTID in the same transaction, so slave state is transactionally consistent. */ - +#ifdef WITH_WSREP /*Set wsrep_affected_rows = 0 */ thd->wsrep_affected_rows= 0; +#endif if (rgi->gtid_pending) { From 2e889de34af19222044977519659ad3a1d378e41 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Wed, 5 Apr 2017 16:24:39 +0530 Subject: [PATCH 33/52] Fix test cases in galera suite Signed-off-by: Sachin Setiya --- mysql-test/include/assert_grep.inc | 154 +++++++++++++++++++ mysql-test/suite/galera/r/GAL-401.result | 3 +- mysql-test/suite/galera/r/lp1376747-4.result | 4 + mysql-test/suite/galera/t/GAL-401.test | 3 +- 4 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 mysql-test/include/assert_grep.inc diff --git a/mysql-test/include/assert_grep.inc b/mysql-test/include/assert_grep.inc new file mode 100644 index 00000000000..a980a6d73b1 --- /dev/null +++ b/mysql-test/include/assert_grep.inc @@ -0,0 +1,154 @@ +# ==== Purpose ==== +# +# Grep a file for a pattern, produce a single string out of the +# matching lines, and assert that the string matches a given regular +# expression. +# +# ==== Usage ==== +# +# --let $assert_text= TEXT +# --let $assert_file= FILE +# --let $assert_select= REGEX +# [--let $assert_match= REGEX | --let $assert_count= NUMBER] +# [--let $assert_only_after= REGEX] +# --source include/assert_grep.inc +# +# Parameters: +# +# $assert_text +# Text that describes what is being checked. This text is written to +# the query log so it should not contain non-deterministic elements. +# +# $assert_file +# File to search. +# +# $assert_select +# All lines matching this text will be checked. +# +# $assert_match +# The script will find all lines that match $assert_select, +# concatenate them to a long string, and assert that it matches +# $assert_match. +# +# $assert_count +# Instead of asserting that the selected lines match +# $assert_match, assert that there were exactly $assert_count +# matching lines. +# +# $assert_only_after +# Reset all the lines matched and the counter when finding this pattern. +# It is useful for searching things in the mysqld.err log file just +# after the last server restart for example (discarding the log content +# of previous server executions). + + +if (!$assert_text) +{ + --die !!!ERROR IN TEST: you must set $assert_text +} +if (!$assert_file) +{ + --die !!!ERROR IN TEST: you must set $assert_file +} +if (!$assert_select) +{ + --die !!!ERROR IN TEST: you must set $assert_select +} +if ($assert_match == '') +{ + if ($assert_count == '') + { + --die !!!ERROR IN TEST: you must set either $assert_match or $assert_count + } +} +if ($assert_match != '') +{ + if ($assert_count != '') + { + --echo assert_text='$assert_text' assert_count='$assert_count' + --die !!!ERROR IN TEST: you must set only one of $assert_match or $assert_count + } +} + + +--let $include_filename= assert_grep.inc [$assert_text] +--source include/begin_include_file.inc + + +--let _AG_ASSERT_TEXT= $assert_text +--let _AG_ASSERT_FILE= $assert_file +--let _AG_ASSERT_SELECT= $assert_select +--let _AG_ASSERT_MATCH= $assert_match +--let _AG_ASSERT_COUNT= $assert_count +--let _AG_OUT= `SELECT CONCAT('$MYSQLTEST_VARDIR/tmp/_ag_', UUID())` +--let _AG_ASSERT_ONLY_AFTER= $assert_only_after + + +--perl + use strict; + use warnings; + my $file= $ENV{'_AG_ASSERT_FILE'}; + my $assert_select= $ENV{'_AG_ASSERT_SELECT'}; + my $assert_match= $ENV{'_AG_ASSERT_MATCH'}; + my $assert_count= $ENV{'_AG_ASSERT_COUNT'}; + my $assert_only_after= $ENV{'_AG_ASSERT_ONLY_AFTER'}; + my $out= $ENV{'_AG_OUT'}; + + my $result= ''; + my $count= 0; + open(FILE, "$file") or die("Error $? opening $file: $!\n"); + while () { + my $line = $_; + if ($assert_only_after && $line =~ /$assert_only_after/) { + $result = ""; + $count = 0; + } + if ($line =~ /$assert_select/) { + if ($assert_count ne '') { + $count++; + } + else { + $result .= $line; + } + } + } + close(FILE) or die("Error $? closing $file: $!"); + open OUT, "> $out" or die("Error $? opening $out: $!"); + if ($assert_count ne '' && ($count != $assert_count)) { + print OUT ($count) or die("Error $? writing $out: $!"); + } + elsif ($assert_count eq '' && $result !~ /$assert_match/) { + print OUT ($result) or die("Error $? writing $out: $!"); + } + else { + print OUT ("assert_grep.inc ok"); + } + close OUT or die("Error $? closing $out: $!"); +EOF + + +--let $_ag_outcome= `SELECT LOAD_FILE('$_AG_OUT')` +if ($_ag_outcome != 'assert_grep.inc ok') +{ + --source include/show_rpl_debug_info.inc + --echo include/assert_grep.inc failed! + --echo assert_text: '$assert_text' + --echo assert_file: '$assert_file' + --echo assert_select: '$assert_select' + --echo assert_match: '$assert_match' + --echo assert_count: '$assert_count' + --echo assert_only_after: '$assert_only_after' + if ($assert_match != '') + { + --echo matching lines: '$_ag_outcome' + } + if ($assert_count != '') + { + --echo number of matching lines: $_ag_outcome + } + --die assert_grep.inc failed. +} + + +--let $include_filename= include/assert_grep.inc [$assert_text] +--source include/end_include_file.inc diff --git a/mysql-test/suite/galera/r/GAL-401.result b/mysql-test/suite/galera/r/GAL-401.result index bcf83e7e1ff..de08fbb5799 100644 --- a/mysql-test/suite/galera/r/GAL-401.result +++ b/mysql-test/suite/galera/r/GAL-401.result @@ -1,6 +1,6 @@ SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; SET @@global.wsrep_desync = 1; -SET SESSION wsrep_sync_wait=0; +SET SESSION wsrep_dirty_reads=1; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; @@ -8,7 +8,6 @@ SHOW STATUS LIKE 'wsrep_desync_count'; Variable_name Value wsrep_desync_count 0 SET @@global.wsrep_desync = 0; -SET SESSION wsrep_sync_wait=7; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/galera/r/lp1376747-4.result b/mysql-test/suite/galera/r/lp1376747-4.result index b0ae2b7fc92..e39b7171a5b 100644 --- a/mysql-test/suite/galera/r/lp1376747-4.result +++ b/mysql-test/suite/galera/r/lp1376747-4.result @@ -2,11 +2,15 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); SET session wsrep_sync_wait=0; SET session wsrep_causal_reads=OFF; +Warnings: +Warning 1287 '@@wsrep_causal_reads' is deprecated and will be removed in a future release. Please use '@@wsrep_sync_wait=1' instead FLUSH TABLE WITH READ LOCK; ALTER TABLE t1 ADD COLUMN f2 INTEGER; INSERT INTO t1 VALUES (2,3); SET session wsrep_sync_wait=0; SET session wsrep_causal_reads=OFF; +Warnings: +Warning 1287 '@@wsrep_causal_reads' is deprecated and will be removed in a future release. Please use '@@wsrep_sync_wait=1' instead SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/galera/t/GAL-401.test b/mysql-test/suite/galera/t/GAL-401.test index 4b7ec95eb68..66015f970c9 100644 --- a/mysql-test/suite/galera/t/GAL-401.test +++ b/mysql-test/suite/galera/t/GAL-401.test @@ -9,7 +9,7 @@ SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; # Desync and disconnect node 2 from the PC: --connection node_2 SET @@global.wsrep_desync = 1; -SET SESSION wsrep_sync_wait=0; +SET SESSION wsrep_dirty_reads=1; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; --let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --source include/wait_condition.inc @@ -41,7 +41,6 @@ SET @@global.wsrep_desync = 0; --let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; --source include/wait_condition.inc -SET SESSION wsrep_sync_wait=7; SHOW CREATE TABLE t1; DROP TABLE t1; CALL mtr.add_suppression("WSREP: Protocol violation. JOIN message sender (.*) is not in state transfer \\(SYNCED\\). Message ignored."); From ea4146229c7d4ca13eae1bc01a3a8d8b8ed42c8a Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Thu, 6 Apr 2017 12:41:55 +0530 Subject: [PATCH 34/52] Fix test failure , and add galera_restart_on_unknown_option to disabled. --- mysql-test/suite/galera/disabled.def | 1 + mysql-test/suite/galera/r/galera_var_slave_threads.result | 1 + mysql-test/suite/galera/t/galera_var_slave_threads.test | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 5a481d116ba..3b4698a7849 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -55,3 +55,4 @@ galera.galera_ist_restart_joiner : MDEV-12319 #Failed to start mysqld galera.galera_ssl_compression : MDEV-12319 #Failed to start mysqld galera.galera_wan : MDEV-12319 #Failed to start mysqld galera.rpl_row_annotate : MDEV-12319 #Failed to start mysqld +galera_restart_on_unknown_option : Solve diff --git a/mysql-test/suite/galera/r/galera_var_slave_threads.result b/mysql-test/suite/galera/r/galera_var_slave_threads.result index 603dfaeacc7..2340d25d160 100644 --- a/mysql-test/suite/galera/r/galera_var_slave_threads.result +++ b/mysql-test/suite/galera/r/galera_var_slave_threads.result @@ -1,3 +1,4 @@ +CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread."); CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; CREATE TABLE t2 (f1 INT AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB; SET GLOBAL wsrep_slave_threads = 0; diff --git a/mysql-test/suite/galera/t/galera_var_slave_threads.test b/mysql-test/suite/galera/t/galera_var_slave_threads.test index 50e22fbef66..5e56800c5d6 100644 --- a/mysql-test/suite/galera/t/galera_var_slave_threads.test +++ b/mysql-test/suite/galera/t/galera_var_slave_threads.test @@ -6,7 +6,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc - +CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread."); --let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads` --connection node_1 From 7dd6efeaab688d703e3569c4f54f30502e88dd2f Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 2 Apr 2017 16:43:43 +1000 Subject: [PATCH 35/52] Don't use full path of libtool This is to be friendly to our OSX users where the libtool path is very different. Ref: * https://github.com/Homebrew/homebrew-core/blob/master/Formula/mariadb.rb#L44..L46 --- cmake/libutils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index 5125b9482cd..2e65e8b5ba3 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -188,7 +188,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) # binaries properly) ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD COMMAND rm ${TARGET_LOCATION} - COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION} + COMMAND libtool -static -o ${TARGET_LOCATION} ${STATIC_LIBS} ) ELSE() From 88613e1df69ab416d43f21551acec340648d0017 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Thu, 1 Dec 2016 09:59:58 +0100 Subject: [PATCH 36/52] MDEV-11201: gtid_ignore_duplicates incorrectly ignores statements when GTID replication is not enabled When master_use_gtid=no, the IO thread loads the slave GTID state from the master during connect. This races with the SQL thread when gtid_ignore_duplicates=1. If an event is in the relay log from before the new connect and has not been applied yet, moving the slave position causes the SQL thread to think that event should be skipped due to gtid_ignore_duplicates=1. This patch simply disables gtid_ignore_duplicates when not using GTID, which seems to be what one would expect. --- sql/rpl_parallel.cc | 3 ++- sql/slave.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index e5964e9c038..43e52c00e8d 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -1109,7 +1109,8 @@ handle_rpl_parallel_thread(void *arg) thd->wait_for_commit_ptr= &rgi->commit_orderer; - if (opt_gtid_ignore_duplicates) + if (opt_gtid_ignore_duplicates && + rgi->rli->mi->using_gtid != Master_info::USE_GTID_NO) { int res= rpl_global_gtid_slave_state->check_duplicate_gtid(&rgi->current_gtid, diff --git a/sql/slave.cc b/sql/slave.cc index 70b1c5b025e..8801e9e9ab5 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3612,7 +3612,8 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, DBUG_RETURN(1); } - if (opt_gtid_ignore_duplicates) + if (opt_gtid_ignore_duplicates && + rli->mi->using_gtid != Master_info::USE_GTID_NO) { int res= rpl_global_gtid_slave_state->check_duplicate_gtid (&serial_rgi->current_gtid, serial_rgi); From 16b2b1eae5e72dc0533e4709815c13803e102b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 8 Apr 2017 16:46:26 +0300 Subject: [PATCH 37/52] Use page_is_leaf() where applicable --- storage/innobase/btr/btr0btr.cc | 2 +- storage/innobase/btr/btr0defragment.cc | 2 +- storage/innobase/dict/dict0stats.cc | 4 ++-- storage/xtradb/btr/btr0btr.cc | 2 +- storage/xtradb/btr/btr0defragment.cc | 2 +- storage/xtradb/dict/dict0stats.cc | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 470825fa246..019ea974ea7 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -3241,7 +3241,7 @@ func_start: btr_page_create(new_block, new_page_zip, cursor->index, btr_page_get_level(page, mtr), mtr); /* Only record the leaf level page splits. */ - if (btr_page_get_level(page, mtr) == 0) { + if (page_is_leaf(page)) { cursor->index->stat_defrag_n_page_split ++; cursor->index->stat_defrag_modified_counter ++; btr_defragment_save_defrag_stats_if_needed(cursor->index); diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc index 26bab936de5..ea7fb116af2 100644 --- a/storage/innobase/btr/btr0defragment.cc +++ b/storage/innobase/btr/btr0defragment.cc @@ -233,7 +233,7 @@ btr_defragment_add_index( return NULL; } - if (btr_page_get_level(page, &mtr) == 0) { + if (page_is_leaf(page)) { // Index root is a leaf page, no need to defragment. mtr_commit(&mtr); return NULL; diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 6a28f3cdf8f..33b6c2e23e0 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1576,7 +1576,7 @@ dict_stats_analyze_index_below_cur( page = buf_block_get_frame(block); - if (btr_page_get_level(page, mtr) == 0) { + if (page_is_leaf(page)) { /* leaf level */ break; } @@ -1620,7 +1620,7 @@ dict_stats_analyze_index_below_cur( } /* make sure we got a leaf page as a result from the above loop */ - ut_ad(btr_page_get_level(page, &mtr) == 0); + ut_ad(page_is_leaf(page)); /* scan the leaf page and find the number of distinct keys, when looking only at the first n_prefix columns; also estimate diff --git a/storage/xtradb/btr/btr0btr.cc b/storage/xtradb/btr/btr0btr.cc index 417eeb2c367..48411b6ff6a 100644 --- a/storage/xtradb/btr/btr0btr.cc +++ b/storage/xtradb/btr/btr0btr.cc @@ -3277,7 +3277,7 @@ func_start: btr_page_create(new_block, new_page_zip, cursor->index, btr_page_get_level(page, mtr), mtr); /* Only record the leaf level page splits. */ - if (btr_page_get_level(page, mtr) == 0) { + if (page_is_leaf(page)) { cursor->index->stat_defrag_n_page_split ++; cursor->index->stat_defrag_modified_counter ++; btr_defragment_save_defrag_stats_if_needed(cursor->index); diff --git a/storage/xtradb/btr/btr0defragment.cc b/storage/xtradb/btr/btr0defragment.cc index 6e7a3fd2411..ca00eed40a9 100644 --- a/storage/xtradb/btr/btr0defragment.cc +++ b/storage/xtradb/btr/btr0defragment.cc @@ -233,7 +233,7 @@ btr_defragment_add_index( return NULL; } - if (btr_page_get_level(page, &mtr) == 0) { + if (page_is_leaf(page)) { // Index root is a leaf page, no need to defragment. mtr_commit(&mtr); return NULL; diff --git a/storage/xtradb/dict/dict0stats.cc b/storage/xtradb/dict/dict0stats.cc index 6a28f3cdf8f..33b6c2e23e0 100644 --- a/storage/xtradb/dict/dict0stats.cc +++ b/storage/xtradb/dict/dict0stats.cc @@ -1576,7 +1576,7 @@ dict_stats_analyze_index_below_cur( page = buf_block_get_frame(block); - if (btr_page_get_level(page, mtr) == 0) { + if (page_is_leaf(page)) { /* leaf level */ break; } @@ -1620,7 +1620,7 @@ dict_stats_analyze_index_below_cur( } /* make sure we got a leaf page as a result from the above loop */ - ut_ad(btr_page_get_level(page, &mtr) == 0); + ut_ad(page_is_leaf(page)); /* scan the leaf page and find the number of distinct keys, when looking only at the first n_prefix columns; also estimate From 3bb32e8682f849413ce994277e9029ba5732baae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 15 Apr 2017 03:36:23 +0300 Subject: [PATCH 38/52] MDEV-10509: Remove excessive server error logging on InnoDB ALTER TABLE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Disable the output that was added in MDEV-6812 if log_warnings=2 or less. Also, remove some redundant messages. TODO: Implement MDEV-12512 to supercede MDEV-6812 and properly report the progress of ALTER TABLE…ALGORITHM=INPLACE. --- storage/innobase/row/row0merge.cc | 90 ++++++++++++++++++++---------- storage/xtradb/row/row0merge.cc | 91 +++++++++++++++++++++---------- 2 files changed, 122 insertions(+), 59 deletions(-) diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 5531263b248..c7c0092e7a4 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -25,6 +26,7 @@ Completed by Sunny Bains and Marko Makela *******************************************************/ #include #include +#include #include "row0merge.h" #include "row0ext.h" @@ -2628,7 +2630,11 @@ row_merge_sort( } #endif /* UNIV_SOLARIS */ - sql_print_information("InnoDB: Online DDL : merge-sorting has estimated %lu runs", num_runs); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL : merge-sorting" + " has estimated " ULINTPF " runs", + num_runs); + } /* Merge the runs until we have one big run */ do { @@ -4057,9 +4063,11 @@ row_merge_build_indexes( duplicate keys. */ innobase_rec_reset(table); - sql_print_information("InnoDB: Online DDL : Start"); - sql_print_information("InnoDB: Online DDL : Start reading clustered " - "index of the table and create temporary files"); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL : Start reading" + " clustered index of the table" + " and create temporary files"); + } pct_cost = COST_READ_CLUSTERED_INDEX * 100 / (total_static_cost + total_dynamic_cost); @@ -4086,8 +4094,11 @@ row_merge_build_indexes( pct_progress += pct_cost; - sql_print_information("InnoDB: Online DDL : End of reading " - "clustered index of the table and create temporary files"); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL : End of reading " + "clustered index of the table" + " and create temporary files"); + } for (i = 0; i < n_indexes; i++) { total_index_blocks += merge_files[i].offset; @@ -4183,8 +4194,7 @@ wait_again: DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Insert\n"); #endif } else if (merge_files[i].fd != -1) { - char buf[3 * NAME_LEN]; - char *bufend; + char buf[NAME_LEN + 1]; row_merge_dup_t dup = { sort_idx, table, col_map, 0}; @@ -4193,18 +4203,25 @@ wait_again: total_index_blocks)) / (total_static_cost + total_dynamic_cost) * PCT_COST_MERGESORT_INDEX * 100; - - bufend = innobase_convert_name( + char* bufend = innobase_convert_name( buf, sizeof buf, - indexes[i]->name, strlen(indexes[i]->name), + indexes[i]->name, + strlen(indexes[i]->name), trx->mysql_thd, FALSE); - buf[bufend - buf]='\0'; - sql_print_information("InnoDB: Online DDL : Start merge-sorting" - " index %s (%lu / %lu), estimated cost : %2.4f", - buf, (i+1), n_indexes, pct_cost); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL :" + " Start merge-sorting" + " index %s" + " (" ULINTPF + " / " ULINTPF ")," + " estimated cost :" + " %2.4f", + buf, i + 1, n_indexes, + pct_cost); + } error = row_merge_sort( trx, &dup, &merge_files[i], @@ -4214,9 +4231,14 @@ wait_again: pct_progress += pct_cost; - sql_print_information("InnoDB: Online DDL : End of " - " merge-sorting index %s (%lu / %lu)", - buf, (i+1), n_indexes); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL :" + " End of " + " merge-sorting index %s" + " (" ULINTPF + " / " ULINTPF ")", + buf, i + 1, n_indexes); + } DBUG_EXECUTE_IF( "ib_merge_wait_after_sort", @@ -4229,10 +4251,15 @@ wait_again: (total_static_cost + total_dynamic_cost) * PCT_COST_INSERT_INDEX * 100; - sql_print_information("InnoDB: Online DDL : Start " - "building index %s (%lu / %lu), estimated " - "cost : %2.4f", buf, (i+1), - n_indexes, pct_cost); + if (global_system_variables.log_warnings > 2) { + sql_print_information( + "InnoDB: Online DDL : Start " + "building index %s" + " (" ULINTPF + " / " ULINTPF "), estimated " + "cost : %2.4f", buf, i + 1, + n_indexes, pct_cost); + } error = row_merge_insert_index_tuples( trx->id, sort_idx, old_table, @@ -4241,9 +4268,13 @@ wait_again: crypt_data, crypt_block, new_table->space); pct_progress += pct_cost; - sql_print_information("InnoDB: Online DDL : " - "End of building index %s (%lu / %lu)", - buf, (i+1), n_indexes); + if (global_system_variables.log_warnings > 2) { + sql_print_information( + "InnoDB: Online DDL : " + "End of building index %s" + " (" ULINTPF " / " ULINTPF ")", + buf, i + 1, n_indexes); + } } } @@ -4260,15 +4291,16 @@ wait_again: ut_ad(sort_idx->online_status == ONLINE_INDEX_COMPLETE); } else { - sql_print_information("InnoDB: Online DDL : Start applying row log"); + if (global_system_variables.log_warnings > 2) { + sql_print_information( + "InnoDB: Online DDL : Applying" + " log to index"); + } DEBUG_SYNC_C("row_log_apply_before"); error = row_log_apply(trx, sort_idx, table); DEBUG_SYNC_C("row_log_apply_after"); - sql_print_information("InnoDB: Online DDL : End of applying row log"); } - sql_print_information("InnoDB: Online DDL : Completed"); - if (error != DB_SUCCESS) { trx->error_key_num = key_numbers[i]; goto func_exit; diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index 8752cf489c9..7651248f463 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2014, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -26,6 +26,7 @@ Completed by Sunny Bains and Marko Makela *******************************************************/ #include #include +#include #include "row0merge.h" #include "row0ext.h" @@ -2635,7 +2636,11 @@ row_merge_sort( thd_progress_init(trx->mysql_thd, 1); } - sql_print_information("InnoDB: Online DDL : merge-sorting has estimated %lu runs", num_runs); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL : merge-sorting" + " has estimated " ULINTPF " runs", + num_runs); + } /* Merge the runs until we have one big run */ do { @@ -4060,9 +4065,11 @@ row_merge_build_indexes( duplicate keys. */ innobase_rec_reset(table); - sql_print_information("InnoDB: Online DDL : Start"); - sql_print_information("InnoDB: Online DDL : Start reading clustered " - "index of the table and create temporary files"); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL : Start reading" + " clustered index of the table" + " and create temporary files"); + } pct_cost = COST_READ_CLUSTERED_INDEX * 100 / (total_static_cost + total_dynamic_cost); @@ -4089,8 +4096,11 @@ row_merge_build_indexes( pct_progress += pct_cost; - sql_print_information("InnoDB: Online DDL : End of reading " - "clustered index of the table and create temporary files"); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL : End of reading " + "clustered index of the table" + " and create temporary files"); + } for (i = 0; i < n_indexes; i++) { total_index_blocks += merge_files[i].offset; @@ -4186,8 +4196,7 @@ wait_again: DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Insert\n"); #endif } else if (merge_files[i].fd != -1) { - char buf[3 * NAME_LEN]; - char *bufend; + char buf[NAME_LEN + 1]; row_merge_dup_t dup = { sort_idx, table, col_map, 0}; @@ -4196,18 +4205,25 @@ wait_again: total_index_blocks)) / (total_static_cost + total_dynamic_cost) * PCT_COST_MERGESORT_INDEX * 100; - - bufend = innobase_convert_name( + char* bufend = innobase_convert_name( buf, sizeof buf, - indexes[i]->name, strlen(indexes[i]->name), + indexes[i]->name, + strlen(indexes[i]->name), trx->mysql_thd, FALSE); - buf[bufend - buf]='\0'; - sql_print_information("InnoDB: Online DDL : Start merge-sorting" - " index %s (%lu / %lu), estimated cost : %2.4f", - buf, (i+1), n_indexes, pct_cost); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL :" + " Start merge-sorting" + " index %s" + " (" ULINTPF + " / " ULINTPF ")," + " estimated cost :" + " %2.4f", + buf, i + 1, n_indexes, + pct_cost); + } error = row_merge_sort( trx, &dup, &merge_files[i], @@ -4217,9 +4233,14 @@ wait_again: pct_progress += pct_cost; - sql_print_information("InnoDB: Online DDL : End of " - " merge-sorting index %s (%lu / %lu)", - buf, (i+1), n_indexes); + if (global_system_variables.log_warnings > 2) { + sql_print_information("InnoDB: Online DDL :" + " End of " + " merge-sorting index %s" + " (" ULINTPF + " / " ULINTPF ")", + buf, i + 1, n_indexes); + } DBUG_EXECUTE_IF( "ib_merge_wait_after_sort", @@ -4232,10 +4253,15 @@ wait_again: (total_static_cost + total_dynamic_cost) * PCT_COST_INSERT_INDEX * 100; - sql_print_information("InnoDB: Online DDL : Start " - "building index %s (%lu / %lu), estimated " - "cost : %2.4f", buf, (i+1), - n_indexes, pct_cost); + if (global_system_variables.log_warnings > 2) { + sql_print_information( + "InnoDB: Online DDL : Start " + "building index %s" + " (" ULINTPF + " / " ULINTPF "), estimated " + "cost : %2.4f", buf, i + 1, + n_indexes, pct_cost); + } error = row_merge_insert_index_tuples( trx->id, sort_idx, old_table, @@ -4244,9 +4270,13 @@ wait_again: crypt_data, crypt_block, new_table->space); pct_progress += pct_cost; - sql_print_information("InnoDB: Online DDL : " - "End of building index %s (%lu / %lu)", - buf, (i+1), n_indexes); + if (global_system_variables.log_warnings > 2) { + sql_print_information( + "InnoDB: Online DDL : " + "End of building index %s" + " (" ULINTPF " / " ULINTPF ")", + buf, i + 1, n_indexes); + } } } @@ -4263,15 +4293,16 @@ wait_again: ut_ad(sort_idx->online_status == ONLINE_INDEX_COMPLETE); } else { - sql_print_information("InnoDB: Online DDL : Start applying row log"); + if (global_system_variables.log_warnings > 2) { + sql_print_information( + "InnoDB: Online DDL : Applying" + " log to index"); + } DEBUG_SYNC_C("row_log_apply_before"); error = row_log_apply(trx, sort_idx, table); DEBUG_SYNC_C("row_log_apply_after"); - sql_print_information("InnoDB: Online DDL : End of applying row log"); } - sql_print_information("InnoDB: Online DDL : Completed"); - if (error != DB_SUCCESS) { trx->error_key_num = key_numbers[i]; goto func_exit; From 107de652b62f2750e8172fd6e894fa0eb80b0501 Mon Sep 17 00:00:00 2001 From: =Ian Gilfillan Date: Wed, 29 Mar 2017 14:53:55 +0200 Subject: [PATCH 39/52] MDEV-11964 my_safe_process, tokuft_logdump stub man pages --- man/CMakeLists.txt | 4 ++-- man/my_safe_process.1 | 16 ++++++++++++++++ man/tokuft_logdump.1 | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 man/my_safe_process.1 create mode 100644 man/tokuft_logdump.1 diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt index cd32f25e4f0..fdefade6c0d 100644 --- a/man/CMakeLists.txt +++ b/man/CMakeLists.txt @@ -26,7 +26,7 @@ SET(MAN1_SERVER innochecksum.1 my_print_defaults.1 myisam_ftdump.1 myisamchk.1 mysqld_safe_helper.1 tokuftdump.1 wsrep_sst_common.1 wsrep_sst_mysqldump.1 wsrep_sst_rsync.1 wsrep_sst_xtrabackup-v2.1 wsrep_sst_xtrabackup.1 - galera_recovery.1 galera_new_cluster.1) + galera_recovery.1 galera_new_cluster.1 tokuft_logdump.1) SET(MAN8_SERVER mysqld.8) SET(MAN1_CLIENT msql2mysql.1 mysql.1 mysql_find_rows.1 mysql_waitpid.1 mysqlaccess.1 mysqladmin.1 mysqlbinlog.1 mysqlcheck.1 @@ -34,7 +34,7 @@ SET(MAN1_CLIENT msql2mysql.1 mysql.1 mysql_find_rows.1 mysql_waitpid.1 mysql_plugin.1) SET(MAN1_DEVEL mysql_config.1) SET(MAN1_TEST mysql-stress-test.pl.1 mysql-test-run.pl.1 mysql_client_test.1 - mysqltest_embedded.1 mysql_client_test_embedded.1) + mysqltest_embedded.1 mysql_client_test_embedded.1 my_safe_process.1) INSTALL(FILES ${MAN1_SERVER} DESTINATION ${INSTALL_MANDIR}/man1 COMPONENT ManPagesServer) INSTALL(FILES ${MAN8_SERVER} DESTINATION ${INSTALL_MANDIR}/man8 COMPONENT ManPagesServer) diff --git a/man/my_safe_process.1 b/man/my_safe_process.1 new file mode 100644 index 00000000000..fac8ed69fc8 --- /dev/null +++ b/man/my_safe_process.1 @@ -0,0 +1,16 @@ +'\" t +.\" +.TH "\FBMY_SAFE_PROCESS\FR" "1" "29 March 2017" "MariaDB 10\&.1" "MariaDB Database System" +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.SH NAME +my_safe_process \- Utility program that encapsulates process creation, monitoring and bulletproof process cleanup +.SH DESCRIPTION +Use: safe_process [options to safe_process] -- progname arg1 \.\.\. argn\. +.PP +For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/ diff --git a/man/tokuft_logdump.1 b/man/tokuft_logdump.1 new file mode 100644 index 00000000000..f6cf08080f7 --- /dev/null +++ b/man/tokuft_logdump.1 @@ -0,0 +1,16 @@ +'\" t +.\" +.TH "\FBTOKUFT_LOGPRINT\FR" "1" "27 March 2017" "MariaDB 10\&.1" "MariaDB Database System" +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.SH NAME +tokuft_logprint \- Dump the log from stdin to stdout +.SH DESCRIPTION +Use: Dump the log from stdin to stdout\. +.PP +For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/ From 5136295b21aac41709672c17a5a596f996a27735 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 2 Apr 2017 20:11:12 +1000 Subject: [PATCH 40/52] OSX: get cache line size --- cmake/cpu_info.cmake | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/cmake/cpu_info.cmake b/cmake/cpu_info.cmake index 32b98142ace..1772510e72b 100644 --- a/cmake/cpu_info.cmake +++ b/cmake/cpu_info.cmake @@ -15,15 +15,29 @@ # Symbols with information about the CPU. -FIND_PROGRAM(GETCONF getconf) -MARK_AS_ADVANCED(GETCONF) +IF(CMAKE_SYSTEM_NAME MATCHES "Darwin") + FIND_PROGRAM(SYSCTL sysctl) + MARK_AS_ADVANCED(SYSCTL) -IF(GETCONF) - EXECUTE_PROCESS( - COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE - OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE - ) + IF(SYSCTL) + EXECUTE_PROCESS( + COMMAND ${SYSCTL} -n hw.cachelinesize + OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE + ) + ENDIF() + +ELSE() + FIND_PROGRAM(GETCONF getconf) + MARK_AS_ADVANCED(GETCONF) + + IF(GETCONF) + EXECUTE_PROCESS( + COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE + OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE + ) + ENDIF() ENDIF() + IF(CPU_LEVEL1_DCACHE_LINESIZE AND CPU_LEVEL1_DCACHE_LINESIZE GREATER 0) ELSE() SET(CPU_LEVEL1_DCACHE_LINESIZE 64) From d34a67b067606f61c9ec6700769770418d5bb47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 19 Apr 2017 22:30:18 +0300 Subject: [PATCH 41/52] MDEV-12534 Use atomic operations whenever available Allow 64-bit atomic operations on 32-bit systems, only relying on HAVE_ATOMIC_BUILTINS_64, disregarding the width of the register file. Define UNIV_WORD_SIZE correctly on all systems, including Windows. In MariaDB 10.0 and 10.1, it was incorrectly defined as 4 on 64-bit Windows. Define HAVE_ATOMIC_BUILTINS_64 on Windows (64-bit atomics are available on both 32-bit and 64-bit Windows platforms; the operations were unnecessarily disabled even on 64-bit Windows). MONITOR_OS_PENDING_READS, MONITOR_OS_PENDING_WRITES: Enable by default. os_file_n_pending_preads, os_file_n_pending_pwrites, os_n_pending_reads, os_n_pending_writes: Remove. Use the monitor counters instead. os_file_count_mutex: Remove. On a system that does not support 64-bit atomics, monitor_mutex will be used instead. --- storage/innobase/buf/buf0rea.cc | 14 +-- storage/innobase/include/os0file.h | 12 +- storage/innobase/include/os0sync.h | 5 +- storage/innobase/include/srv0mon.h | 62 ++++++--- storage/innobase/include/univ.i | 12 +- storage/innobase/os/os0file.cc | 196 +++++++---------------------- storage/innobase/srv/srv0mon.cc | 5 +- storage/innobase/srv/srv0srv.cc | 4 +- storage/innobase/sync/sync0arr.cc | 7 +- storage/xtradb/buf/buf0rea.cc | 14 +-- storage/xtradb/include/os0file.h | 12 +- storage/xtradb/include/os0sync.h | 5 +- storage/xtradb/include/srv0mon.h | 62 ++++++--- storage/xtradb/include/univ.i | 12 +- storage/xtradb/os/os0file.cc | 181 +++++++------------------- storage/xtradb/srv/srv0mon.cc | 5 +- storage/xtradb/srv/srv0srv.cc | 4 +- storage/xtradb/sync/sync0arr.cc | 7 +- 18 files changed, 214 insertions(+), 405 deletions(-) diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 7c8369c0c09..27f45308813 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -881,15 +881,11 @@ buf_read_recv_pages( count++; if (count > 1000) { - fprintf(stderr, - "InnoDB: Error: InnoDB has waited for" - " 10 seconds for pending\n" - "InnoDB: reads to the buffer pool to" - " be finished.\n" - "InnoDB: Number of pending reads %lu," - " pending pread calls %lu\n", - (ulong) buf_pool->n_pend_reads, - (ulong) os_file_n_pending_preads); + ib_logf(IB_LOG_LEVEL_ERROR, + "waited for 10 seconds for " ULINTPF + " pending reads to the buffer pool to" + " be finished", + buf_pool->n_pend_reads); os_aio_print_debug = TRUE; } diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index 6cb4f54d629..bdb4682eafb 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. -Copyright (c) 2017, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2013, 2017, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Percona Inc.. Those modifications are @@ -51,16 +51,6 @@ extern ibool os_has_said_disk_full; /** Flag: enable debug printout for asynchronous i/o */ extern ibool os_aio_print_debug; -/** Number of pending os_file_pread() operations */ -extern ulint os_file_n_pending_preads; -/** Number of pending os_file_pwrite() operations */ -extern ulint os_file_n_pending_pwrites; - -/** Number of pending read operations */ -extern ulint os_n_pending_reads; -/** Number of pending write operations */ -extern ulint os_n_pending_writes; - #ifdef __WIN__ /** We define always WIN_ASYNC_IO, and check at run-time whether diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h index 0754210c47a..dd6de43dc0b 100644 --- a/storage/innobase/include/os0sync.h +++ b/storage/innobase/include/os0sync.h @@ -667,10 +667,7 @@ os_atomic_clear(volatile lock_word_t* ptr) # define HAVE_ATOMIC_BUILTINS # define HAVE_ATOMIC_BUILTINS_BYTE - -# ifndef _WIN32 -# define HAVE_ATOMIC_BUILTINS_64 -# endif +# define HAVE_ATOMIC_BUILTINS_64 /**********************************************************//** Atomic compare and exchange of signed integers (both 32 and 64 bit). diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index 2d90f47eefe..09af5d4159b 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -2,6 +2,7 @@ Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -541,22 +542,30 @@ on the counters */ /** Increment a monitor counter under mutex protection. Use MONITOR_INC if appropriate mutex protection already exists. +@param mutex mutex to acquire and release @param monitor monitor to be incremented by 1 -@param mutex mutex to acquire and relese */ -# define MONITOR_MUTEX_INC(mutex, monitor) \ +@param enabled whether the monitor is enabled */ +#define MONITOR_MUTEX_INC_LOW(mutex, monitor, enabled) \ ut_ad(!mutex_own(mutex)); \ - if (MONITOR_IS_ON(monitor)) { \ + if (enabled) { \ mutex_enter(mutex); \ if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \ MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \ } \ mutex_exit(mutex); \ } +/** Increment a monitor counter under mutex protection. +Use MONITOR_INC if appropriate mutex protection already exists. +@param mutex mutex to acquire and release +@param monitor monitor to be incremented by 1 */ +#define MONITOR_MUTEX_INC(mutex, monitor) \ + MONITOR_MUTEX_INC_LOW(mutex, monitor, MONITOR_IS_ON(monitor)) /** Decrement a monitor counter under mutex protection. Use MONITOR_DEC if appropriate mutex protection already exists. +@param mutex mutex to acquire and release @param monitor monitor to be decremented by 1 -@param mutex mutex to acquire and relese */ -# define MONITOR_MUTEX_DEC(mutex, monitor) \ +@param enabled whether the monitor is enabled */ +#define MONITOR_MUTEX_DEC_LOW(mutex, monitor, enabled) \ ut_ad(!mutex_own(mutex)); \ if (MONITOR_IS_ON(monitor)) { \ mutex_enter(mutex); \ @@ -565,13 +574,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists. } \ mutex_exit(mutex); \ } +/** Decrement a monitor counter under mutex protection. +Use MONITOR_DEC if appropriate mutex protection already exists. +@param mutex mutex to acquire and release +@param monitor monitor to be decremented by 1 */ +#define MONITOR_MUTEX_DEC(mutex, monitor) \ + MONITOR_MUTEX_DEC_LOW(mutex, monitor, MONITOR_IS_ON(monitor)) #if defined HAVE_ATOMIC_BUILTINS_64 /** Atomically increment a monitor counter. Use MONITOR_INC if appropriate mutex protection exists. -@param monitor monitor to be incremented by 1 */ -# define MONITOR_ATOMIC_INC(monitor) \ - if (MONITOR_IS_ON(monitor)) { \ +@param monitor monitor to be incremented by 1 +@param enabled whether the monitor is enabled */ +# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \ + if (enabled) { \ ib_uint64_t value; \ value = os_atomic_increment_uint64( \ (ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \ @@ -584,9 +600,10 @@ Use MONITOR_INC if appropriate mutex protection exists. /** Atomically decrement a monitor counter. Use MONITOR_DEC if appropriate mutex protection exists. -@param monitor monitor to be decremented by 1 */ -# define MONITOR_ATOMIC_DEC(monitor) \ - if (MONITOR_IS_ON(monitor)) { \ +@param monitor monitor to be decremented by 1 +@param enabled whether the monitor is enabled */ +# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \ + if (enabled) { \ ib_uint64_t value; \ value = os_atomic_decrement_uint64( \ (ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \ @@ -617,14 +634,29 @@ srv_mon_free(void); /** Atomically increment a monitor counter. Use MONITOR_INC if appropriate mutex protection exists. -@param monitor monitor to be incremented by 1 */ -# define MONITOR_ATOMIC_INC(monitor) MONITOR_MUTEX_INC(&monitor_mutex, monitor) +@param monitor monitor to be incremented by 1 +@param enabled whether the monitor is enabled */ +# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \ + MONITOR_MUTEX_INC_LOW(&monitor_mutex, monitor, enabled) /** Atomically decrement a monitor counter. Use MONITOR_DEC if appropriate mutex protection exists. -@param monitor monitor to be decremented by 1 */ -# define MONITOR_ATOMIC_DEC(monitor) MONITOR_MUTEX_DEC(&monitor_mutex, monitor) +@param monitor monitor to be decremented by 1 +@param enabled whether the monitor is enabled */ +# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \ + MONITOR_MUTEX_DEC_LOW(&monitor_mutex, monitor, enabled) #endif /* HAVE_ATOMIC_BUILTINS_64 */ +/** Atomically increment a monitor counter if it is enabled. +Use MONITOR_INC if appropriate mutex protection exists. +@param monitor monitor to be incremented by 1 */ +#define MONITOR_ATOMIC_INC(monitor) \ + MONITOR_ATOMIC_INC_LOW(monitor, MONITOR_IS_ON(monitor)) +/** Atomically decrement a monitor counter if it is enabled. +Use MONITOR_DEC if appropriate mutex protection exists. +@param monitor monitor to be decremented by 1 */ +#define MONITOR_ATOMIC_DEC(monitor) \ + MONITOR_ATOMIC_DEC_LOW(monitor, MONITOR_IS_ON(monitor)) + #define MONITOR_DEC(monitor) \ if (MONITOR_IS_ON(monitor)) { \ MONITOR_VALUE(monitor)--; \ diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 824a06829f9..fc0bf0aeeca 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -285,22 +285,12 @@ definitions: */ #endif /* !UNIV_MUST_NOT_INLINE */ -#ifdef _WIN32 -#define UNIV_WORD_SIZE 4 -#elif defined(_WIN64) -#define UNIV_WORD_SIZE 8 -#else -/** MySQL config.h generated by GNU autoconf will define SIZEOF_LONG in Posix */ -#define UNIV_WORD_SIZE SIZEOF_LONG -#endif +#define UNIV_WORD_SIZE SIZEOF_SIZE_T /** The following alignment is used in memory allocations in memory heap management to ensure correct alignment for doubles etc. */ #define UNIV_MEM_ALIGNMENT 8 -/** The following alignment is used in aligning lints etc. */ -#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE - /* DATABASE VERSION CONTROL ======================== diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index eb8b3a53d32..ff67c90eecf 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. -Copyright (c) 2012, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2013, 2017, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Percona Inc.. Those modifications are @@ -284,21 +284,6 @@ UNIV_INTERN time_t os_last_printout; UNIV_INTERN ibool os_has_said_disk_full = FALSE; -#if !defined(UNIV_HOTBACKUP) \ - && (!defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8) -/** The mutex protecting the following counts of pending I/O operations */ -static os_ib_mutex_t os_file_count_mutex; -#endif /* !UNIV_HOTBACKUP && (!HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8) */ - -/** Number of pending os_file_pread() operations */ -UNIV_INTERN ulint os_file_n_pending_preads = 0; -/** Number of pending os_file_pwrite() operations */ -UNIV_INTERN ulint os_file_n_pending_pwrites = 0; -/** Number of pending write operations */ -UNIV_INTERN ulint os_n_pending_writes = 0; -/** Number of pending read operations */ -UNIV_INTERN ulint os_n_pending_reads = 0; - #ifdef UNIV_DEBUG # ifndef UNIV_HOTBACKUP /**********************************************************************//** @@ -752,10 +737,6 @@ void os_io_init_simple(void) /*===================*/ { -#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 - os_file_count_mutex = os_mutex_create(); -#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8 */ - for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) { os_file_seek_mutexes[i] = os_mutex_create(); } @@ -2364,9 +2345,6 @@ os_file_pread( os_offset_t offset) /*!< in: file offset from where to read */ { off_t offs; -#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD) - ssize_t n_bytes; -#endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */ ut_ad(n); @@ -2383,33 +2361,12 @@ os_file_pread( os_n_file_reads++; -#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD) -#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 - (void) os_atomic_increment_ulint(&os_n_pending_reads, 1); - (void) os_atomic_increment_ulint(&os_file_n_pending_preads, 1); - MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS); -#else - os_mutex_enter(os_file_count_mutex); - os_file_n_pending_preads++; - os_n_pending_reads++; - MONITOR_INC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); -#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */ - - n_bytes = pread(file, buf, n, offs); - -#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 - (void) os_atomic_decrement_ulint(&os_n_pending_reads, 1); - (void) os_atomic_decrement_ulint(&os_file_n_pending_preads, 1); - MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_READS); -#else - os_mutex_enter(os_file_count_mutex); - os_file_n_pending_preads--; - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); -#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD == 8 */ + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS); +#ifdef HAVE_PREAD + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor); + ssize_t n_bytes = pread(file, buf, n, offs); + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); return(n_bytes); #else { @@ -2419,15 +2376,7 @@ os_file_pread( ulint i; #endif /* !UNIV_HOTBACKUP */ -#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 - (void) os_atomic_increment_ulint(&os_n_pending_reads, 1); - MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS); -#else - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads++; - MONITOR_INC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); -#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */ + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor); #ifndef UNIV_HOTBACKUP /* Protect the seek / read operation with a mutex */ i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; @@ -2447,16 +2396,7 @@ os_file_pread( os_mutex_exit(os_file_seek_mutexes[i]); #endif /* !UNIV_HOTBACKUP */ -#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 - (void) os_atomic_decrement_ulint(&os_n_pending_reads, 1); - MONITOR_ATOIC_DEC(MONITOR_OS_PENDING_READS); -#else - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); -#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD_SIZE == 8 */ - + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); return(ret); } #endif @@ -2493,32 +2433,11 @@ os_file_pwrite( os_n_file_writes++; -#if defined(HAVE_PWRITE) && !defined(HAVE_BROKEN_PREAD) -#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 - os_mutex_enter(os_file_count_mutex); - os_file_n_pending_pwrites++; - os_n_pending_writes++; - MONITOR_INC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); -#else - (void) os_atomic_increment_ulint(&os_n_pending_writes, 1); - (void) os_atomic_increment_ulint(&os_file_n_pending_pwrites, 1); - MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_WRITES); -#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */ - + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES); +#ifdef HAVE_PWRITE + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor); ret = pwrite(file, buf, (ssize_t) n, offs); - -#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 - os_mutex_enter(os_file_count_mutex); - os_file_n_pending_pwrites--; - os_n_pending_writes--; - MONITOR_DEC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); -#else - (void) os_atomic_decrement_ulint(&os_n_pending_writes, 1); - (void) os_atomic_decrement_ulint(&os_file_n_pending_pwrites, 1); - MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_WRITES); -#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */ + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor); return(ret); #else @@ -2528,10 +2447,7 @@ os_file_pwrite( ulint i; # endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes++; - MONITOR_INC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor); # ifndef UNIV_HOTBACKUP /* Protect the seek / write operation with a mutex */ @@ -2555,14 +2471,10 @@ func_exit: os_mutex_exit(os_file_seek_mutexes[i]); # endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes--; - MONITOR_DEC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); - + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor); return(ret); } -#endif /* !UNIV_HOTBACKUP */ +#endif /* HAVE_PWRITE */ } #endif @@ -2597,6 +2509,7 @@ os_file_read_func( os_n_file_reads++; os_bytes_read_since_printout += n; + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS); try_again: ut_ad(buf); @@ -2605,10 +2518,7 @@ try_again: low = (DWORD) offset & 0xFFFFFFFF; high = (DWORD) (offset >> 32); - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads++; - MONITOR_INC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor); #ifndef UNIV_HOTBACKUP /* Protect the seek / read operation with a mutex */ @@ -2626,11 +2536,7 @@ try_again: os_mutex_exit(os_file_seek_mutexes[i]); #endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); - + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); goto error_handling; } @@ -2640,10 +2546,7 @@ try_again: os_mutex_exit(os_file_seek_mutexes[i]); #endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); if (ret && len == n) { return(TRUE); @@ -2728,6 +2631,7 @@ os_file_read_no_error_handling_func( os_n_file_reads++; os_bytes_read_since_printout += n; + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS); try_again: ut_ad(buf); @@ -2736,10 +2640,7 @@ try_again: low = (DWORD) offset & 0xFFFFFFFF; high = (DWORD) (offset >> 32); - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads++; - MONITOR_INC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor); #ifndef UNIV_HOTBACKUP /* Protect the seek / read operation with a mutex */ @@ -2757,11 +2658,7 @@ try_again: os_mutex_exit(os_file_seek_mutexes[i]); #endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); - + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); goto error_handling; } @@ -2771,10 +2668,7 @@ try_again: os_mutex_exit(os_file_seek_mutexes[i]); #endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); if (ret && len == n) { return(TRUE); @@ -2854,7 +2748,6 @@ os_file_write_func( ulint n) /*!< in: number of bytes to write */ { ut_ad(!srv_read_only_mode); - #ifdef __WIN__ BOOL ret; DWORD len; @@ -2876,14 +2769,12 @@ os_file_write_func( ut_ad(buf); ut_ad(n > 0); + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES); retry: low = (DWORD) offset & 0xFFFFFFFF; high = (DWORD) (offset >> 32); - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes++; - MONITOR_INC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor); #ifndef UNIV_HOTBACKUP /* Protect the seek / write operation with a mutex */ @@ -2901,10 +2792,7 @@ retry: os_mutex_exit(os_file_seek_mutexes[i]); #endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes--; - MONITOR_DEC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor); ut_print_timestamp(stderr); @@ -2928,10 +2816,7 @@ retry: os_mutex_exit(os_file_seek_mutexes[i]); #endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes--; - MONITOR_DEC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor); if (ret && len == n) { @@ -5751,19 +5636,24 @@ os_aio_print( time_elapsed = 0.001 + difftime(current_time, os_last_printout); fprintf(file, - "Pending flushes (fsync) log: %lu; buffer pool: %lu\n" - "%lu OS file reads, %lu OS file writes, %lu OS fsyncs\n", - (ulong) fil_n_pending_log_flushes, - (ulong) fil_n_pending_tablespace_flushes, - (ulong) os_n_file_reads, - (ulong) os_n_file_writes, - (ulong) os_n_fsyncs); + "Pending flushes (fsync) log: " ULINTPF + "; buffer pool: " ULINTPF "\n" + ULINTPF " OS file reads, " + ULINTPF " OS file writes, " + ULINTPF " OS fsyncs\n", + fil_n_pending_log_flushes, + fil_n_pending_tablespace_flushes, + os_n_file_reads, + os_n_file_writes, + os_n_fsyncs); - if (os_file_n_pending_preads != 0 || os_file_n_pending_pwrites != 0) { + const ulint n_reads = MONITOR_VALUE(MONITOR_OS_PENDING_READS); + const ulint n_writes = MONITOR_VALUE(MONITOR_OS_PENDING_WRITES); + + if (n_reads != 0 || n_writes != 0) { fprintf(file, - "%lu pending preads, %lu pending pwrites\n", - (ulong) os_file_n_pending_preads, - (ulong) os_file_n_pending_pwrites); + ULINTPF " pending reads, " ULINTPF " pending writes\n", + n_reads, n_writes); } if (os_n_file_reads == os_n_file_reads_old) { diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index 4a709160ea6..ea21a4c1454 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -2,6 +2,7 @@ Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -643,11 +644,11 @@ static monitor_info_t innodb_counter_info[] = MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC}, {"os_pending_reads", "os", "Number of reads pending", - MONITOR_NONE, + MONITOR_DEFAULT_ON, MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS}, {"os_pending_writes", "os", "Number of writes pending", - MONITOR_NONE, + MONITOR_DEFAULT_ON, MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES}, {"os_log_bytes_written", "os", diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 723ae838f07..58e69c3c9e7 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1409,10 +1409,10 @@ srv_export_innodb_status(void) mutex_enter(&srv_innodb_monitor_mutex); export_vars.innodb_data_pending_reads = - os_n_pending_reads; + MONITOR_VALUE(MONITOR_OS_PENDING_READS); export_vars.innodb_data_pending_writes = - os_n_pending_writes; + MONITOR_VALUE(MONITOR_OS_PENDING_WRITES); export_vars.innodb_data_pending_fsyncs = fil_n_pending_log_flushes diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc index c7163695a3f..6ffe3cab8c8 100644 --- a/storage/innobase/sync/sync0arr.cc +++ b/storage/innobase/sync/sync0arr.cc @@ -1069,9 +1069,10 @@ sync_array_print_long_waits( now the values of pending calls of these. */ fprintf(stderr, - "InnoDB: Pending preads %lu, pwrites %lu\n", - (ulong) os_file_n_pending_preads, - (ulong) os_file_n_pending_pwrites); + "InnoDB: Pending reads " UINT64PF + ", writes " UINT64PF "\n", + MONITOR_VALUE(MONITOR_OS_PENDING_READS), + MONITOR_VALUE(MONITOR_OS_PENDING_WRITES)); srv_print_innodb_monitor = TRUE; os_event_set(srv_monitor_event); diff --git a/storage/xtradb/buf/buf0rea.cc b/storage/xtradb/buf/buf0rea.cc index c28df72df92..9053f38924e 100644 --- a/storage/xtradb/buf/buf0rea.cc +++ b/storage/xtradb/buf/buf0rea.cc @@ -986,15 +986,11 @@ not_to_recover: count++; if (count > 1000) { - fprintf(stderr, - "InnoDB: Error: InnoDB has waited for" - " 10 seconds for pending\n" - "InnoDB: reads to the buffer pool to" - " be finished.\n" - "InnoDB: Number of pending reads %lu," - " pending pread calls %lu\n", - (ulong) buf_pool->n_pend_reads, - (ulong) os_file_n_pending_preads); + ib_logf(IB_LOG_LEVEL_ERROR, + "waited for 10 seconds for " ULINTPF + " pending reads to the buffer pool to" + " be finished", + buf_pool->n_pend_reads); os_aio_print_debug = TRUE; } diff --git a/storage/xtradb/include/os0file.h b/storage/xtradb/include/os0file.h index 60a9c3475e7..b8f30977fbe 100644 --- a/storage/xtradb/include/os0file.h +++ b/storage/xtradb/include/os0file.h @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. -Copyright (c) 2017, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2013, 2017, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Percona Inc.. Those modifications are @@ -52,16 +52,6 @@ extern ibool os_has_said_disk_full; /** Flag: enable debug printout for asynchronous i/o */ extern ibool os_aio_print_debug; -/** Number of pending os_file_pread() operations */ -extern ulint os_file_n_pending_preads; -/** Number of pending os_file_pwrite() operations */ -extern ulint os_file_n_pending_pwrites; - -/** Number of pending read operations */ -extern ulint os_n_pending_reads; -/** Number of pending write operations */ -extern ulint os_n_pending_writes; - #ifdef __WIN__ /** We define always WIN_ASYNC_IO, and check at run-time whether diff --git a/storage/xtradb/include/os0sync.h b/storage/xtradb/include/os0sync.h index f6207555f1a..48c56a73369 100644 --- a/storage/xtradb/include/os0sync.h +++ b/storage/xtradb/include/os0sync.h @@ -718,10 +718,7 @@ os_atomic_clear(volatile lock_word_t* ptr) # define HAVE_ATOMIC_BUILTINS # define HAVE_ATOMIC_BUILTINS_BYTE - -# ifndef _WIN32 -# define HAVE_ATOMIC_BUILTINS_64 -# endif +# define HAVE_ATOMIC_BUILTINS_64 /**********************************************************//** Atomic compare and exchange of signed integers (both 32 and 64 bit). diff --git a/storage/xtradb/include/srv0mon.h b/storage/xtradb/include/srv0mon.h index 2d90f47eefe..09af5d4159b 100644 --- a/storage/xtradb/include/srv0mon.h +++ b/storage/xtradb/include/srv0mon.h @@ -2,6 +2,7 @@ Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -541,22 +542,30 @@ on the counters */ /** Increment a monitor counter under mutex protection. Use MONITOR_INC if appropriate mutex protection already exists. +@param mutex mutex to acquire and release @param monitor monitor to be incremented by 1 -@param mutex mutex to acquire and relese */ -# define MONITOR_MUTEX_INC(mutex, monitor) \ +@param enabled whether the monitor is enabled */ +#define MONITOR_MUTEX_INC_LOW(mutex, monitor, enabled) \ ut_ad(!mutex_own(mutex)); \ - if (MONITOR_IS_ON(monitor)) { \ + if (enabled) { \ mutex_enter(mutex); \ if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \ MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \ } \ mutex_exit(mutex); \ } +/** Increment a monitor counter under mutex protection. +Use MONITOR_INC if appropriate mutex protection already exists. +@param mutex mutex to acquire and release +@param monitor monitor to be incremented by 1 */ +#define MONITOR_MUTEX_INC(mutex, monitor) \ + MONITOR_MUTEX_INC_LOW(mutex, monitor, MONITOR_IS_ON(monitor)) /** Decrement a monitor counter under mutex protection. Use MONITOR_DEC if appropriate mutex protection already exists. +@param mutex mutex to acquire and release @param monitor monitor to be decremented by 1 -@param mutex mutex to acquire and relese */ -# define MONITOR_MUTEX_DEC(mutex, monitor) \ +@param enabled whether the monitor is enabled */ +#define MONITOR_MUTEX_DEC_LOW(mutex, monitor, enabled) \ ut_ad(!mutex_own(mutex)); \ if (MONITOR_IS_ON(monitor)) { \ mutex_enter(mutex); \ @@ -565,13 +574,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists. } \ mutex_exit(mutex); \ } +/** Decrement a monitor counter under mutex protection. +Use MONITOR_DEC if appropriate mutex protection already exists. +@param mutex mutex to acquire and release +@param monitor monitor to be decremented by 1 */ +#define MONITOR_MUTEX_DEC(mutex, monitor) \ + MONITOR_MUTEX_DEC_LOW(mutex, monitor, MONITOR_IS_ON(monitor)) #if defined HAVE_ATOMIC_BUILTINS_64 /** Atomically increment a monitor counter. Use MONITOR_INC if appropriate mutex protection exists. -@param monitor monitor to be incremented by 1 */ -# define MONITOR_ATOMIC_INC(monitor) \ - if (MONITOR_IS_ON(monitor)) { \ +@param monitor monitor to be incremented by 1 +@param enabled whether the monitor is enabled */ +# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \ + if (enabled) { \ ib_uint64_t value; \ value = os_atomic_increment_uint64( \ (ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \ @@ -584,9 +600,10 @@ Use MONITOR_INC if appropriate mutex protection exists. /** Atomically decrement a monitor counter. Use MONITOR_DEC if appropriate mutex protection exists. -@param monitor monitor to be decremented by 1 */ -# define MONITOR_ATOMIC_DEC(monitor) \ - if (MONITOR_IS_ON(monitor)) { \ +@param monitor monitor to be decremented by 1 +@param enabled whether the monitor is enabled */ +# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \ + if (enabled) { \ ib_uint64_t value; \ value = os_atomic_decrement_uint64( \ (ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \ @@ -617,14 +634,29 @@ srv_mon_free(void); /** Atomically increment a monitor counter. Use MONITOR_INC if appropriate mutex protection exists. -@param monitor monitor to be incremented by 1 */ -# define MONITOR_ATOMIC_INC(monitor) MONITOR_MUTEX_INC(&monitor_mutex, monitor) +@param monitor monitor to be incremented by 1 +@param enabled whether the monitor is enabled */ +# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \ + MONITOR_MUTEX_INC_LOW(&monitor_mutex, monitor, enabled) /** Atomically decrement a monitor counter. Use MONITOR_DEC if appropriate mutex protection exists. -@param monitor monitor to be decremented by 1 */ -# define MONITOR_ATOMIC_DEC(monitor) MONITOR_MUTEX_DEC(&monitor_mutex, monitor) +@param monitor monitor to be decremented by 1 +@param enabled whether the monitor is enabled */ +# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \ + MONITOR_MUTEX_DEC_LOW(&monitor_mutex, monitor, enabled) #endif /* HAVE_ATOMIC_BUILTINS_64 */ +/** Atomically increment a monitor counter if it is enabled. +Use MONITOR_INC if appropriate mutex protection exists. +@param monitor monitor to be incremented by 1 */ +#define MONITOR_ATOMIC_INC(monitor) \ + MONITOR_ATOMIC_INC_LOW(monitor, MONITOR_IS_ON(monitor)) +/** Atomically decrement a monitor counter if it is enabled. +Use MONITOR_DEC if appropriate mutex protection exists. +@param monitor monitor to be decremented by 1 */ +#define MONITOR_ATOMIC_DEC(monitor) \ + MONITOR_ATOMIC_DEC_LOW(monitor, MONITOR_IS_ON(monitor)) + #define MONITOR_DEC(monitor) \ if (MONITOR_IS_ON(monitor)) { \ MONITOR_VALUE(monitor)--; \ diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index 6acb0eec319..7497e7f5d05 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -304,22 +304,12 @@ definitions: */ #endif /* !UNIV_MUST_NOT_INLINE */ -#ifdef _WIN32 -#define UNIV_WORD_SIZE 4 -#elif defined(_WIN64) -#define UNIV_WORD_SIZE 8 -#else -/** MySQL config.h generated by GNU autoconf will define SIZEOF_LONG in Posix */ -#define UNIV_WORD_SIZE SIZEOF_LONG -#endif +#define UNIV_WORD_SIZE SIZEOF_SIZE_T /** The following alignment is used in memory allocations in memory heap management to ensure correct alignment for doubles etc. */ #define UNIV_MEM_ALIGNMENT 8 -/** The following alignment is used in aligning lints etc. */ -#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE - /* DATABASE VERSION CONTROL ======================== diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc index a30b688ad74..48ae49f28e4 100644 --- a/storage/xtradb/os/os0file.cc +++ b/storage/xtradb/os/os0file.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2013, 2017, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Percona Inc.. Those modifications are @@ -291,21 +291,6 @@ UNIV_INTERN time_t os_last_printout; UNIV_INTERN ibool os_has_said_disk_full = FALSE; -#if !defined(UNIV_HOTBACKUP) \ - && (!defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8) -/** The mutex protecting the following counts of pending I/O operations */ -static os_ib_mutex_t os_file_count_mutex; -#endif /* !UNIV_HOTBACKUP && (!HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8) */ - -/** Number of pending os_file_pread() operations */ -UNIV_INTERN ulint os_file_n_pending_preads = 0; -/** Number of pending os_file_pwrite() operations */ -UNIV_INTERN ulint os_file_n_pending_pwrites = 0; -/** Number of pending write operations */ -UNIV_INTERN ulint os_n_pending_writes = 0; -/** Number of pending read operations */ -UNIV_INTERN ulint os_n_pending_reads = 0; - #ifdef UNIV_DEBUG # ifndef UNIV_HOTBACKUP /**********************************************************************//** @@ -887,10 +872,6 @@ void os_io_init_simple(void) /*===================*/ { -#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 - os_file_count_mutex = os_mutex_create(); -#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8 */ - for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) { os_file_seek_mutexes[i] = os_mutex_create(); } @@ -2580,10 +2561,6 @@ os_file_pread( trx_t* trx) { off_t offs; -#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD) - ssize_t n_bytes; - ssize_t n_read; -#endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */ ulint sec; ulint ms; ib_uint64_t start_time; @@ -2613,22 +2590,16 @@ os_file_pread( } else { start_time = 0; } -#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD) -#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 - (void) os_atomic_increment_ulint(&os_n_pending_reads, 1); - (void) os_atomic_increment_ulint(&os_file_n_pending_preads, 1); - MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS); -#else - os_mutex_enter(os_file_count_mutex); - os_file_n_pending_preads++; - os_n_pending_reads++; - MONITOR_INC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); -#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */ + + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS); +#ifdef HAVE_PREAD + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor); + + ssize_t n_bytes; /* Handle partial reads and signal interruptions correctly */ for (n_bytes = 0; n_bytes < (ssize_t) n; ) { - n_read = pread(file, buf, (ssize_t)n - n_bytes, offs); + ssize_t n_read = pread(file, buf, (ssize_t)n - n_bytes, offs); if (n_read > 0) { n_bytes += n_read; offs += n_read; @@ -2640,17 +2611,7 @@ os_file_pread( } } -#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 - (void) os_atomic_decrement_ulint(&os_n_pending_reads, 1); - (void) os_atomic_decrement_ulint(&os_file_n_pending_preads, 1); - MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_READS); -#else - os_mutex_enter(os_file_count_mutex); - os_file_n_pending_preads--; - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); -#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD == 8 */ + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); if (UNIV_UNLIKELY(start_time != 0)) { @@ -2669,15 +2630,7 @@ os_file_pread( ulint i; #endif /* !UNIV_HOTBACKUP */ -#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 - (void) os_atomic_increment_ulint(&os_n_pending_reads, 1); - MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS); -#else - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads++; - MONITOR_INC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); -#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */ + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor); #ifndef UNIV_HOTBACKUP /* Protect the seek / read operation with a mutex */ i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES; @@ -2707,15 +2660,7 @@ os_file_pread( os_mutex_exit(os_file_seek_mutexes[i]); #endif /* !UNIV_HOTBACKUP */ -#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8 - (void) os_atomic_decrement_ulint(&os_n_pending_reads, 1); - MONITOR_ATOIC_DEC(MONITOR_OS_PENDING_READS); -#else - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); -#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD_SIZE == 8 */ + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); if (UNIV_UNLIKELY(start_time != 0) { @@ -2761,18 +2706,9 @@ os_file_pwrite( os_n_file_writes++; -#if defined(HAVE_PWRITE) && !defined(HAVE_BROKEN_PREAD) -#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 - os_mutex_enter(os_file_count_mutex); - os_file_n_pending_pwrites++; - os_n_pending_writes++; - MONITOR_INC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); -#else - (void) os_atomic_increment_ulint(&os_n_pending_writes, 1); - (void) os_atomic_increment_ulint(&os_file_n_pending_pwrites, 1); - MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_WRITES); -#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */ + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES); +#ifdef HAVE_PWRITE + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor); /* Handle partial writes and signal interruptions correctly */ for (ret = 0; ret < (ssize_t) n; ) { @@ -2791,17 +2727,7 @@ os_file_pwrite( } } -#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 - os_mutex_enter(os_file_count_mutex); - os_file_n_pending_pwrites--; - os_n_pending_writes--; - MONITOR_DEC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); -#else - (void) os_atomic_decrement_ulint(&os_n_pending_writes, 1); - (void) os_atomic_decrement_ulint(&os_file_n_pending_pwrites, 1); - MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_WRITES); -#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */ + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor); return(ret); #else @@ -2811,10 +2737,7 @@ os_file_pwrite( ulint i; # endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes++; - MONITOR_INC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor); # ifndef UNIV_HOTBACKUP /* Protect the seek / write operation with a mutex */ @@ -2848,14 +2771,10 @@ func_exit: os_mutex_exit(os_file_seek_mutexes[i]); # endif /* !UNIV_HOTBACKUP */ - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes--; - MONITOR_DEC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); - + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor); return(ret); } -#endif /* !UNIV_HOTBACKUP */ +#endif /* HAVE_PWRITE */ } #endif @@ -2887,15 +2806,13 @@ os_file_read_func( os_n_file_reads++; os_bytes_read_since_printout += n; + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS); try_again: ut_ad(buf); ut_ad(n > 0); - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads++; - MONITOR_INC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor); memset (&overlapped, 0, sizeof (overlapped)); overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF); @@ -2908,10 +2825,7 @@ try_again: else if(GetLastError() == ERROR_IO_PENDING) { ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE); } - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); if (ret && len == n) { return(TRUE); @@ -2995,15 +2909,13 @@ os_file_read_no_error_handling_func( os_n_file_reads++; os_bytes_read_since_printout += n; + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS); try_again: ut_ad(buf); ut_ad(n > 0); - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads++; - MONITOR_INC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor); memset (&overlapped, 0, sizeof (overlapped)); overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF); @@ -3016,10 +2928,7 @@ try_again: else if(GetLastError() == ERROR_IO_PENDING) { ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE); } - os_mutex_enter(os_file_count_mutex); - os_n_pending_reads--; - MONITOR_DEC(MONITOR_OS_PENDING_READS); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); if (ret && len == n) { return(TRUE); @@ -3113,12 +3022,10 @@ os_file_write_func( ut_ad(buf); ut_ad(n > 0); + const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES); retry: - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes++; - MONITOR_INC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor); memset (&overlapped, 0, sizeof (overlapped)); overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF); @@ -3133,10 +3040,7 @@ retry: ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE); } - os_mutex_enter(os_file_count_mutex); - os_n_pending_writes--; - MONITOR_DEC(MONITOR_OS_PENDING_WRITES); - os_mutex_exit(os_file_count_mutex); + MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor); if (ret && len == n) { @@ -4230,10 +4134,6 @@ os_aio_free(void) } } -#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 - os_mutex_free(os_file_count_mutex); -#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8 */ - for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) { os_mutex_free(os_file_seek_mutexes[i]); } @@ -5909,19 +5809,24 @@ os_aio_print( time_elapsed = 0.001 + difftime(current_time, os_last_printout); fprintf(file, - "Pending flushes (fsync) log: %lu; buffer pool: %lu\n" - "%lu OS file reads, %lu OS file writes, %lu OS fsyncs\n", - (ulong) fil_n_pending_log_flushes, - (ulong) fil_n_pending_tablespace_flushes, - (ulong) os_n_file_reads, - (ulong) os_n_file_writes, - (ulong) os_n_fsyncs); + "Pending flushes (fsync) log: " ULINTPF + "; buffer pool: " ULINTPF "\n" + ULINTPF " OS file reads, " + ULINTPF " OS file writes, " + ULINTPF " OS fsyncs\n", + fil_n_pending_log_flushes, + fil_n_pending_tablespace_flushes, + os_n_file_reads, + os_n_file_writes, + os_n_fsyncs); - if (os_file_n_pending_preads != 0 || os_file_n_pending_pwrites != 0) { + const ulint n_reads = MONITOR_VALUE(MONITOR_OS_PENDING_READS); + const ulint n_writes = MONITOR_VALUE(MONITOR_OS_PENDING_WRITES); + + if (n_reads != 0 || n_writes != 0) { fprintf(file, - "%lu pending preads, %lu pending pwrites\n", - (ulong) os_file_n_pending_preads, - (ulong) os_file_n_pending_pwrites); + ULINTPF " pending reads, " ULINTPF " pending writes\n", + n_reads, n_writes); } if (os_n_file_reads == os_n_file_reads_old) { diff --git a/storage/xtradb/srv/srv0mon.cc b/storage/xtradb/srv/srv0mon.cc index 4a709160ea6..ea21a4c1454 100644 --- a/storage/xtradb/srv/srv0mon.cc +++ b/storage/xtradb/srv/srv0mon.cc @@ -2,6 +2,7 @@ Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -643,11 +644,11 @@ static monitor_info_t innodb_counter_info[] = MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC}, {"os_pending_reads", "os", "Number of reads pending", - MONITOR_NONE, + MONITOR_DEFAULT_ON, MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS}, {"os_pending_writes", "os", "Number of writes pending", - MONITOR_NONE, + MONITOR_DEFAULT_ON, MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES}, {"os_log_bytes_written", "os", diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc index ffa1e36ebcd..c47119e63cf 100644 --- a/storage/xtradb/srv/srv0srv.cc +++ b/storage/xtradb/srv/srv0srv.cc @@ -1735,10 +1735,10 @@ srv_export_innodb_status(void) mutex_enter(&srv_innodb_monitor_mutex); export_vars.innodb_data_pending_reads = - os_n_pending_reads; + MONITOR_VALUE(MONITOR_OS_PENDING_READS); export_vars.innodb_data_pending_writes = - os_n_pending_writes; + MONITOR_VALUE(MONITOR_OS_PENDING_WRITES); export_vars.innodb_data_pending_fsyncs = fil_n_pending_log_flushes diff --git a/storage/xtradb/sync/sync0arr.cc b/storage/xtradb/sync/sync0arr.cc index e16eddae80c..7325cb49145 100644 --- a/storage/xtradb/sync/sync0arr.cc +++ b/storage/xtradb/sync/sync0arr.cc @@ -1161,9 +1161,10 @@ sync_array_print_long_waits( now the values of pending calls of these. */ fprintf(stderr, - "InnoDB: Pending preads %lu, pwrites %lu\n", - (ulong) os_file_n_pending_preads, - (ulong) os_file_n_pending_pwrites); + "InnoDB: Pending reads " UINT64PF + ", writes " UINT64PF "\n", + MONITOR_VALUE(MONITOR_OS_PENDING_READS), + MONITOR_VALUE(MONITOR_OS_PENDING_WRITES)); srv_print_innodb_monitor = TRUE; os_event_set(srv_monitor_event); From 87b6df31c4ae97c09dc67e370978112fe39764bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Apr 2017 04:36:50 +0300 Subject: [PATCH 42/52] MDEV-12488 Remove type mismatch in InnoDB printf-like calls This is a reduced version of an originally much larger patch. We will keep the definition of the ulint, lint data types unchanged, and we will not be replacing fprintf() calls with ib_logf(). On Windows, use the standard format strings instead of nonstandard extensions. This patch fixes some errors in format strings. Most notably, an IMPORT TABLESPACE error message in InnoDB was displaying the number of columns instead of the mismatching flags. --- extra/innochecksum.cc | 34 +++-- .../suite/innodb/r/innodb-wl5522,xtradb.rdiff | 56 -------- .../suite/innodb/r/innodb-wl5522.result | 12 +- storage/innobase/include/univ.i | 16 +-- storage/innobase/log/log0recv.cc | 6 +- storage/innobase/row/row0import.cc | 128 +++++++++-------- storage/innobase/row/row0merge.cc | 65 +++++---- storage/xtradb/include/univ.i | 16 +-- storage/xtradb/log/log0recv.cc | 6 +- storage/xtradb/row/row0import.cc | 131 +++++++++--------- storage/xtradb/row/row0merge.cc | 66 +++++---- 11 files changed, 238 insertions(+), 298 deletions(-) delete mode 100644 mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc index c09458630c8..04807334baa 100644 --- a/extra/innochecksum.cc +++ b/extra/innochecksum.cc @@ -360,12 +360,13 @@ int main(int argc, char **argv) { if (verbose) printf("Number of pages: "); - printf("%lu\n", pages); + printf(ULINTPF "\n", pages); goto ok; } else if (verbose) { - printf("file %s = %llu bytes (%lu pages)...\n", filename, size, (ulong)pages); + printf("file %s = %llu bytes (" ULINTPF " pages)...\n", + filename, size, pages); if (do_one_page) printf("InnoChecksum; checking page %lu\n", do_page); else @@ -421,7 +422,8 @@ int main(int argc, char **argv) if (compressed) { /* compressed pages */ if (!page_zip_verify_checksum(buf, physical_page_size)) { - fprintf(stderr, "Fail; page %lu invalid (fails compressed page checksum).\n", ct); + fprintf(stderr, "Fail; page " ULINTPF + " invalid (fails compressed page checksum).\n", ct); if (!skip_corrupt) goto error; } @@ -431,10 +433,14 @@ int main(int argc, char **argv) logseq= mach_read_from_4(buf + FIL_PAGE_LSN + 4); logseqfield= mach_read_from_4(buf + logical_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM + 4); if (debug) - printf("page %lu: log sequence number: first = %lu; second = %lu\n", ct, logseq, logseqfield); + printf("page " ULINTPF + ": log sequence number: first = " ULINTPF + "; second = " ULINTPF "\n", + ct, logseq, logseqfield); if (logseq != logseqfield) { - fprintf(stderr, "Fail; page %lu invalid (fails log sequence number check)\n", ct); + fprintf(stderr, "Fail; page " ULINTPF + " invalid (fails log sequence number check)\n", ct); if (!skip_corrupt) goto error; } @@ -443,10 +449,14 @@ int main(int argc, char **argv) oldcsum= buf_calc_page_old_checksum(buf); oldcsumfield= mach_read_from_4(buf + logical_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM); if (debug) - printf("page %lu: old style: calculated = %lu; recorded = %lu\n", ct, oldcsum, oldcsumfield); + printf("page " ULINTPF + ": old style: calculated = " ULINTPF + "; recorded = " ULINTPF "\n", + ct, oldcsum, oldcsumfield); if (oldcsumfield != mach_read_from_4(buf + FIL_PAGE_LSN) && oldcsumfield != oldcsum) { - fprintf(stderr, "Fail; page %lu invalid (fails old style checksum)\n", ct); + fprintf(stderr, "Fail; page " ULINTPF + " invalid (fails old style checksum)\n", ct); if (!skip_corrupt) goto error; } @@ -456,11 +466,14 @@ int main(int argc, char **argv) crc32= buf_calc_page_crc32(buf); csumfield= mach_read_from_4(buf + FIL_PAGE_SPACE_OR_CHKSUM); if (debug) - printf("page %lu: new style: calculated = %lu; crc32 = %lu; recorded = %lu\n", + printf("page " ULINTPF + ": new style: calculated = " ULINTPF + "; crc32 = " ULINTPF "; recorded = " ULINTPF "\n", ct, csum, crc32, csumfield); if (csumfield != 0 && crc32 != csumfield && csum != csumfield) { - fprintf(stderr, "Fail; page %lu invalid (fails innodb and crc32 checksum)\n", ct); + fprintf(stderr, "Fail; page " ULINTPF + " invalid (fails innodb and crc32 checksum)\n", ct); if (!skip_corrupt) goto error; } @@ -479,7 +492,8 @@ int main(int argc, char **argv) if (!lastt) lastt= now; if (now - lastt >= 1) { - printf("page %lu okay: %.3f%% done\n", (ct - 1), (float) ct / pages * 100); + printf("page " ULINTPF " okay: %.3f%% done\n", + (ct - 1), (float) ct / pages * 100); lastt= now; } } diff --git a/mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff b/mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff deleted file mode 100644 index 4aea0b451ec..00000000000 --- a/mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff +++ /dev/null @@ -1,56 +0,0 @@ ---- suite/innodb/r/innodb-wl5522.result -+++ suite/innodb/r/innodb-wl5522.reject -@@ -580,7 +580,7 @@ - ERROR HY000: Tablespace has been discarded for table 't1' - restore: t1 .ibd and .cfg files - ALTER TABLE t1 IMPORT TABLESPACE; --ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0) -+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x0) - unlink: t1.ibd - unlink: t1.cfg - DROP TABLE t1; -@@ -592,7 +592,7 @@ - ERROR HY000: Tablespace has been discarded for table 't1' - restore: t1 .ibd and .cfg files - ALTER TABLE t1 IMPORT TABLESPACE; --ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0) -+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x0) - unlink: t1.ibd - unlink: t1.cfg - DROP TABLE t1; -@@ -766,7 +766,7 @@ - ERROR HY000: Tablespace has been discarded for table 't1' - restore: t1 .ibd and .cfg files - ALTER TABLE t1 IMPORT TABLESPACE; --ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1) -+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x1) - unlink: t1.ibd - unlink: t1.cfg - DROP TABLE t1; -@@ -778,7 +778,7 @@ - ERROR HY000: Tablespace has been discarded for table 't1' - restore: t1 .ibd and .cfg files - ALTER TABLE t1 IMPORT TABLESPACE; --ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1) -+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1) - unlink: t1.ibd - unlink: t1.cfg - DROP TABLE t1; -@@ -955,7 +955,7 @@ - ERROR HY000: Tablespace has been discarded for table 't1' - restore: t1 .ibd and .cfg files - ALTER TABLE t1 IMPORT TABLESPACE; --ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21) -+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x21) - unlink: t1.ibd - unlink: t1.cfg - DROP TABLE t1; -@@ -967,7 +967,7 @@ - ERROR HY000: Tablespace has been discarded for table 't1' - restore: t1 .ibd and .cfg files - ALTER TABLE t1 IMPORT TABLESPACE; --ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21) -+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x21) - unlink: t1.ibd - unlink: t1.cfg - DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-wl5522.result b/mysql-test/suite/innodb/r/innodb-wl5522.result index fb4ac37b9fd..2116dfbf3fa 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5522.result +++ b/mysql-test/suite/innodb/r/innodb-wl5522.result @@ -580,7 +580,7 @@ SELECT * FROM t1; ERROR HY000: Tablespace has been discarded for table 't1' restore: t1 .ibd and .cfg files ALTER TABLE t1 IMPORT TABLESPACE; -ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0) +ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x0) unlink: t1.ibd unlink: t1.cfg DROP TABLE t1; @@ -592,7 +592,7 @@ SELECT * FROM t1; ERROR HY000: Tablespace has been discarded for table 't1' restore: t1 .ibd and .cfg files ALTER TABLE t1 IMPORT TABLESPACE; -ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0) +ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x0) unlink: t1.ibd unlink: t1.cfg DROP TABLE t1; @@ -766,7 +766,7 @@ SELECT * FROM t1; ERROR HY000: Tablespace has been discarded for table 't1' restore: t1 .ibd and .cfg files ALTER TABLE t1 IMPORT TABLESPACE; -ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1) +ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x1) unlink: t1.ibd unlink: t1.cfg DROP TABLE t1; @@ -778,7 +778,7 @@ SELECT * FROM t1; ERROR HY000: Tablespace has been discarded for table 't1' restore: t1 .ibd and .cfg files ALTER TABLE t1 IMPORT TABLESPACE; -ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1) +ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1) unlink: t1.ibd unlink: t1.cfg DROP TABLE t1; @@ -955,7 +955,7 @@ SELECT * FROM t1; ERROR HY000: Tablespace has been discarded for table 't1' restore: t1 .ibd and .cfg files ALTER TABLE t1 IMPORT TABLESPACE; -ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21) +ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x21) unlink: t1.ibd unlink: t1.cfg DROP TABLE t1; @@ -967,7 +967,7 @@ SELECT * FROM t1; ERROR HY000: Tablespace has been discarded for table 't1' restore: t1 .ibd and .cfg files ALTER TABLE t1 IMPORT TABLESPACE; -ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21) +ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x21) unlink: t1.ibd unlink: t1.cfg DROP TABLE t1; diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index fc0bf0aeeca..eff834503ad 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -419,13 +419,12 @@ the word size of the machine, that is on a 32-bit platform 32 bits, and on a macro ULINTPF. */ -#ifdef __WIN__ +#ifdef _WIN32 /* Use the integer types and formatting strings defined in Visual Studio. */ -# define UINT32PF "%I32u" -# define INT64PF "%I64d" -# define UINT64PF "%I64u" -# define UINT64PFx "%016I64x" -# define DBUG_LSN_PF "%llu" +# define UINT32PF "%u" +# define INT64PF "%lld" +# define UINT64PF "%llu" +# define UINT64PFx "%016llx" typedef __int64 ib_int64_t; typedef unsigned __int64 ib_uint64_t; typedef unsigned __int32 ib_uint32_t; @@ -435,13 +434,12 @@ typedef unsigned __int32 ib_uint32_t; # define INT64PF "%" PRId64 # define UINT64PF "%" PRIu64 # define UINT64PFx "%016" PRIx64 -# define DBUG_LSN_PF UINT64PF typedef int64_t ib_int64_t; typedef uint64_t ib_uint64_t; typedef uint32_t ib_uint32_t; -# endif /* __WIN__ */ +#endif -# define IB_ID_FMT UINT64PF +#define IB_ID_FMT UINT64PF #ifdef _WIN64 typedef unsigned __int64 ulint; diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index a90041aaa90..ec9c2795d0a 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1702,7 +1702,7 @@ recv_recover_page_func( } DBUG_PRINT("ib_log", - ("apply " DBUG_LSN_PF ": %u len %u " + ("apply " LSN_PF ": %u len %u " "page %u:%u", recv->start_lsn, (unsigned) recv->type, (unsigned) recv->len, @@ -2350,7 +2350,7 @@ loop: recv_sys->recovered_lsn = new_recovered_lsn; DBUG_PRINT("ib_log", - ("scan " DBUG_LSN_PF ": log rec %u len %u " + ("scan " LSN_PF ": log rec %u len %u " "page %u:%u", old_lsn, (unsigned) type, (unsigned) len, (unsigned) space, (unsigned) page_no)); @@ -2441,7 +2441,7 @@ loop: #endif /* UNIV_LOG_DEBUG */ DBUG_PRINT("ib_log", - ("scan " DBUG_LSN_PF ": multi-log rec %u " + ("scan " LSN_PF ": multi-log rec %u " "len %u page %u:%u", recv_sys->recovered_lsn, (unsigned) type, (unsigned) len, diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 12609c3a65d..da8e1aab2c9 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -573,8 +574,8 @@ AbstractCallback::init( } else if (!is_compressed_table() && m_page_size != UNIV_PAGE_SIZE) { ib_logf(IB_LOG_LEVEL_ERROR, - "Page size %lu of ibd file is not the same " - "as the server page size %lu", + "Page size " ULINTPF " of ibd file is not the same " + "as the server page size " ULINTPF, m_page_size, UNIV_PAGE_SIZE); return(DB_CORRUPTION); @@ -583,8 +584,8 @@ AbstractCallback::init( ib_logf(IB_LOG_LEVEL_ERROR, "File size " UINT64PF " is not a multiple " - "of the page size %lu", - (ib_uint64_t) file_size, (ulong) m_page_size); + "of the page size " ULINTPF, + (ib_uint64_t) file_size, m_page_size); return(DB_CORRUPTION); } @@ -725,8 +726,8 @@ FetchIndexRootPages::operator() ( if (block->page.offset * m_page_size != offset) { ib_logf(IB_LOG_LEVEL_ERROR, "Page offset doesn't match file offset: " - "page offset: %lu, file offset: %lu", - (ulint) block->page.offset, + "page offset: %u, file offset: " ULINTPF, + block->page.offset, (ulint) (offset / m_page_size)); err = DB_CORRUPTION; @@ -1159,10 +1160,9 @@ row_import::match_index_columns( ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Index field count %lu doesn't match" - " tablespace metadata file value %lu", - (ulong) index->n_fields, - (ulong) cfg_index->m_n_fields); + "Index field count %u doesn't match" + " tablespace metadata file value " ULINTPF, + index->n_fields, cfg_index->m_n_fields); return(DB_ERROR); } @@ -1179,34 +1179,31 @@ row_import::match_index_columns( ER_TABLE_SCHEMA_MISMATCH, "Index field name %s doesn't match" " tablespace metadata field name %s" - " for field position %lu", - field->name, cfg_field->name, (ulong) i); + " for field position " ULINTPF, + field->name, cfg_field->name, i); err = DB_ERROR; } if (cfg_field->prefix_len != field->prefix_len) { ib_errf(thd, IB_LOG_LEVEL_ERROR, - ER_TABLE_SCHEMA_MISMATCH, - "Index %s field %s prefix len %lu" - " doesn't match metadata file value" - " %lu", - index->name, field->name, - (ulong) field->prefix_len, - (ulong) cfg_field->prefix_len); + ER_TABLE_SCHEMA_MISMATCH, + "Index %s field %s prefix len %u" + " doesn't match metadata file value %u", + index->name, field->name, + field->prefix_len, cfg_field->prefix_len); err = DB_ERROR; } if (cfg_field->fixed_len != field->fixed_len) { ib_errf(thd, IB_LOG_LEVEL_ERROR, - ER_TABLE_SCHEMA_MISMATCH, - "Index %s field %s fixed len %lu" - " doesn't match metadata file value" - " %lu", - index->name, field->name, - (ulong) field->fixed_len, - (ulong) cfg_field->fixed_len); + ER_TABLE_SCHEMA_MISMATCH, + "Index %s field %s fixed len %u" + " doesn't match metadata file value %u", + index->name, field->name, + field->fixed_len, + cfg_field->fixed_len); err = DB_ERROR; } @@ -1248,12 +1245,11 @@ row_import::match_table_columns( } else if (cfg_col_index != col->ind) { ib_errf(thd, IB_LOG_LEVEL_ERROR, - ER_TABLE_SCHEMA_MISMATCH, - "Column %s ordinal value mismatch, it's at " - "%lu in the table and %lu in the tablespace " - "meta-data file", - col_name, - (ulong) col->ind, (ulong) cfg_col_index); + ER_TABLE_SCHEMA_MISMATCH, + "Column %s ordinal value mismatch, it's at %u" + " in the table and " ULINTPF + " in the tablespace meta-data file", + col_name, col->ind, cfg_col_index); err = DB_ERROR; } else { @@ -1336,19 +1332,19 @@ row_import::match_schema( { /* Do some simple checks. */ - if (m_flags != m_table->flags) { + if ((m_table->flags ^ m_flags) & ~DICT_TF_MASK_DATA_DIR) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Table flags don't match, server table has 0x%lx " - "and the meta-data file has 0x%lx", - (ulong) m_table->n_cols, (ulong) m_flags); + "Table flags don't match, server table has 0x%x" + " and the meta-data file has 0x%lx", + m_table->flags, ulong(m_flags)); return(DB_ERROR); } else if (m_table->n_cols != m_n_cols) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Number of columns don't match, table has %lu " - "columns but the tablespace meta-data file has " - "%lu columns", - (ulong) m_table->n_cols, (ulong) m_n_cols); + "Number of columns don't match, table has %u" + " columns but the tablespace meta-data file has " + ULINTPF " columns", + m_table->n_cols, m_n_cols); return(DB_ERROR); } else if (UT_LIST_GET_LEN(m_table->indexes) != m_n_indexes) { @@ -1358,11 +1354,10 @@ row_import::match_schema( table matching the IMPORT definition. */ ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Number of indexes don't match, table has %lu " - "indexes but the tablespace meta-data file has " - "%lu indexes", - (ulong) UT_LIST_GET_LEN(m_table->indexes), - (ulong) m_n_indexes); + "Number of indexes don't match, table has " ULINTPF + " indexes but the tablespace meta-data file has " + ULINTPF " indexes", + UT_LIST_GET_LEN(m_table->indexes), m_n_indexes); return(DB_ERROR); } @@ -1438,8 +1433,8 @@ row_import::set_root_by_heuristic() UNIV_NOTHROW table_name, sizeof(table_name), m_table->name, FALSE); ib_logf(IB_LOG_LEVEL_WARN, - "Table %s should have %lu indexes but the tablespace " - "has %lu indexes", + "Table %s should have " ULINTPF + " indexes but the tablespace has " ULINTPF " indexes", table_name, UT_LIST_GET_LEN(m_table->indexes), m_n_indexes); @@ -1677,9 +1672,10 @@ PageConverter::adjust_cluster_index_blob_column( ib_errf(m_trx->mysql_thd, IB_LOG_LEVEL_ERROR, ER_INNODB_INDEX_CORRUPT, - "Externally stored column(%lu) has a reference " - "length of %lu in the cluster index %s", - (ulong) i, (ulong) len, index_name); + "Externally stored column(" ULINTPF + ") has a reference length of " ULINTPF + " in the cluster index %s", + i, len, index_name); return(DB_CORRUPTION); } @@ -2040,7 +2036,8 @@ PageConverter::update_page( return(err); } - ib_logf(IB_LOG_LEVEL_WARN, "Unknown page type (%lu)", page_type); + ib_logf(IB_LOG_LEVEL_WARN, "Unknown page type (" ULINTPF ")", + page_type); return(DB_CORRUPTION); } @@ -2074,7 +2071,8 @@ PageConverter::validate( if (checksum != 0) { /* Checksum check passed in buf_page_is_corrupted(). */ ib_logf(IB_LOG_LEVEL_WARN, - "%s: Page %lu checksum %lu should be zero.", + "%s: Page %lu checksum " ULINTPF + " should be zero.", m_filepath, (ulong) (offset / m_page_size), checksum); } @@ -2388,11 +2386,10 @@ row_import_adjust_root_pages_of_secondary_indexes( ib_errf(trx->mysql_thd, IB_LOG_LEVEL_WARN, ER_INNODB_INDEX_CORRUPT, - "Index '%s' contains %lu entries, " - "should be %lu, you should recreate " + "Index '%s' contains " ULINTPF " entries, " + "should be " ULINTPF ", you should recreate " "this index.", index_name, - (ulong) purge.get_n_rows(), - (ulong) n_rows_in_table); + purge.get_n_rows(), n_rows_in_table); index->type |= DICT_CORRUPT; @@ -2743,7 +2740,7 @@ row_import_read_index_data( if (len > OS_FILE_MAX_PATH) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_INNODB_INDEX_CORRUPT, - "Index name length (%lu) is too long, " + "Index name length (" ULINTPF ") is too long, " "the meta-data is corrupt", len); return(DB_CORRUPTION); @@ -2824,8 +2821,8 @@ row_import_read_indexes( } else if (cfg->m_n_indexes > 1024) { // FIXME: What is the upper limit? */ ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR, - "Number of indexes in meta-data file is too high: %lu", - (ulong) cfg->m_n_indexes); + "Number of indexes in meta-data file is too high: " + ULINTPF, cfg->m_n_indexes); cfg->m_n_indexes = 0; return(DB_CORRUPTION); @@ -2923,8 +2920,8 @@ row_import_read_columns( if (len == 0 || len > 128) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR, - "Column name length %lu, is invalid", - (ulong) len); + "Column name length " ULINTPF ", is invalid", + len); return(DB_CORRUPTION); } @@ -3095,8 +3092,9 @@ row_import_read_v1( ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, "Tablespace to be imported has a different " "page size than this server. Server page size " - "is %lu, whereas tablespace page size is %lu", - UNIV_PAGE_SIZE, (ulong) cfg->m_page_size); + "is " ULINTPF ", whereas tablespace page size is " + ULINTPF, + UNIV_PAGE_SIZE, cfg->m_page_size); return(DB_ERROR); } @@ -3161,8 +3159,8 @@ row_import_read_meta_data( return(row_import_read_v1(file, thd, &cfg)); default: ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR, - "Unsupported meta-data version number (%lu), " - "file ignored", (ulong) cfg.m_version); + "Unsupported meta-data version number (" ULINTPF "), " + "file ignored", cfg.m_version); } return(DB_ERROR); diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index f214633e9ce..33345c2e6f2 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -95,7 +96,8 @@ row_merge_tuple_print( } ut_print_buf(f, dfield_get_data(field), len); if (len != field_len) { - fprintf(f, " (total %lu bytes)", field_len); + fprintf(f, " (total " ULINTPF " bytes)", + field_len); } } } @@ -781,9 +783,9 @@ row_merge_buf_write( ut_ad(b < &block[srv_sort_buf_size]); #ifdef UNIV_DEBUG if (row_merge_print_write) { - fprintf(stderr, "row_merge_buf_write %p,%d,%lu %lu", - (void*) b, of->fd, (ulong) of->offset, - (ulong) i); + fprintf(stderr, "row_merge_buf_write %p,%d," + ULINTPF " " ULINTPF, + (void*) b, of->fd, of->offset, i); row_merge_tuple_print(stderr, entry, n_fields); } #endif /* UNIV_DEBUG */ @@ -800,8 +802,8 @@ row_merge_buf_write( #endif /* UNIV_DEBUG_VALGRIND */ #ifdef UNIV_DEBUG if (row_merge_print_write) { - fprintf(stderr, "row_merge_buf_write %p,%d,%lu EOF\n", - (void*) b, of->fd, (ulong) of->offset); + fprintf(stderr, "row_merge_buf_write %p,%d," ULINTPF " EOF\n", + (void*) b, of->fd, of->offset); } #endif /* UNIV_DEBUG */ } @@ -857,15 +859,8 @@ row_merge_read( #ifdef UNIV_DEBUG if (row_merge_print_block_read) { - fprintf(stderr, "row_merge_read fd=%d ofs=%lu\n", - fd, (ulong) offset); - } -#endif /* UNIV_DEBUG */ - -#ifdef UNIV_DEBUG - if (row_merge_print_block_read) { - fprintf(stderr, "row_merge_read fd=%d ofs=%lu\n", - fd, (ulong) offset); + fprintf(stderr, "row_merge_read fd=%d ofs=" ULINTPF "\n", + fd, offset); } #endif /* UNIV_DEBUG */ @@ -908,8 +903,8 @@ row_merge_write( #ifdef UNIV_DEBUG if (row_merge_print_block_write) { - fprintf(stderr, "row_merge_write fd=%d ofs=%lu\n", - fd, (ulong) offset); + fprintf(stderr, "row_merge_write fd=%d ofs=" ULINTPF "\n", + fd, offset); } #endif /* UNIV_DEBUG */ @@ -957,9 +952,10 @@ row_merge_read_rec( *mrec = NULL; #ifdef UNIV_DEBUG if (row_merge_print_read) { - fprintf(stderr, "row_merge_read %p,%p,%d,%lu EOF\n", + fprintf(stderr, "row_merge_read %p,%p,%d," ULINTPF + " EOF\n", (const void*) b, (const void*) block, - fd, (ulong) *foffs); + fd, *foffs); } #endif /* UNIV_DEBUG */ return(NULL); @@ -1074,9 +1070,9 @@ err_exit: func_exit: #ifdef UNIV_DEBUG if (row_merge_print_read) { - fprintf(stderr, "row_merge_read %p,%p,%d,%lu ", + fprintf(stderr, "row_merge_read %p,%p,%d," ULINTPF " ", (const void*) b, (const void*) block, - fd, (ulong) *foffs); + fd, *foffs); rec_print_comp(stderr, *mrec, offsets); putc('\n', stderr); } @@ -1110,8 +1106,8 @@ row_merge_write_rec_low( ut_ad(e == rec_offs_extra_size(offsets) + 1); if (row_merge_print_write) { - fprintf(stderr, "row_merge_write %p,%d,%lu ", - (void*) b, fd, (ulong) foffs); + fprintf(stderr, "row_merge_write %p,%d," ULINTPF " ", + (void*) b, fd, foffs); rec_print_comp(stderr, mrec, offsets); putc('\n', stderr); } @@ -1213,8 +1209,8 @@ row_merge_write_eof( ut_ad(foffs); #ifdef UNIV_DEBUG if (row_merge_print_write) { - fprintf(stderr, "row_merge_write %p,%p,%d,%lu EOF\n", - (void*) b, (void*) block, fd, (ulong) *foffs); + fprintf(stderr, "row_merge_write %p,%p,%d," ULINTPF " EOF\n", + (void*) b, (void*) block, fd, *foffs); } #endif /* UNIV_DEBUG */ @@ -2053,11 +2049,12 @@ row_merge_blocks( #ifdef UNIV_DEBUG if (row_merge_print_block) { fprintf(stderr, - "row_merge_blocks fd=%d ofs=%lu + fd=%d ofs=%lu" - " = fd=%d ofs=%lu\n", - file->fd, (ulong) *foffs0, - file->fd, (ulong) *foffs1, - of->fd, (ulong) of->offset); + "row_merge_blocks fd=%d ofs=" ULINTPF + " + fd=%d ofs=" ULINTPF + " = fd=%d ofs=" ULINTPF "\n", + file->fd, *foffs0, + file->fd, *foffs1, + of->fd, of->offset); } #endif /* UNIV_DEBUG */ @@ -2156,10 +2153,10 @@ row_merge_blocks_copy( #ifdef UNIV_DEBUG if (row_merge_print_block) { fprintf(stderr, - "row_merge_blocks_copy fd=%d ofs=%lu" - " = fd=%d ofs=%lu\n", - file->fd, (ulong) foffs0, - of->fd, (ulong) of->offset); + "row_merge_blocks_copy fd=%d ofs=" ULINTPF + " = fd=%d ofs=" ULINTPF "\n", + file->fd, *foffs0, + of->fd, of->offset); } #endif /* UNIV_DEBUG */ diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index 7497e7f5d05..fff5c0a67a1 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -438,13 +438,12 @@ the word size of the machine, that is on a 32-bit platform 32 bits, and on a macro ULINTPF. */ -#ifdef __WIN__ +#ifdef _WIN32 /* Use the integer types and formatting strings defined in Visual Studio. */ -# define UINT32PF "%I32u" -# define INT64PF "%I64d" -# define UINT64PF "%I64u" -# define UINT64PFx "%016I64x" -# define DBUG_LSN_PF "%llu" +# define UINT32PF "%u" +# define INT64PF "%lld" +# define UINT64PF "%llu" +# define UINT64PFx "%016llx" typedef __int64 ib_int64_t; typedef unsigned __int64 ib_uint64_t; typedef unsigned __int32 ib_uint32_t; @@ -454,13 +453,12 @@ typedef unsigned __int32 ib_uint32_t; # define INT64PF "%" PRId64 # define UINT64PF "%" PRIu64 # define UINT64PFx "%016" PRIx64 -# define DBUG_LSN_PF UINT64PF typedef int64_t ib_int64_t; typedef uint64_t ib_uint64_t; typedef uint32_t ib_uint32_t; -# endif /* __WIN__ */ +#endif -# define IB_ID_FMT UINT64PF +#define IB_ID_FMT UINT64PF #ifdef _WIN64 typedef unsigned __int64 ulint; diff --git a/storage/xtradb/log/log0recv.cc b/storage/xtradb/log/log0recv.cc index afb8b7f00b8..4edfb1e4347 100644 --- a/storage/xtradb/log/log0recv.cc +++ b/storage/xtradb/log/log0recv.cc @@ -1792,7 +1792,7 @@ recv_recover_page_func( } DBUG_PRINT("ib_log", - ("apply " DBUG_LSN_PF ": %u len %u " + ("apply " LSN_PF ": %u len %u " "page %u:%u", recv->start_lsn, (unsigned) recv->type, (unsigned) recv->len, @@ -2440,7 +2440,7 @@ loop: recv_sys->recovered_lsn = new_recovered_lsn; DBUG_PRINT("ib_log", - ("scan " DBUG_LSN_PF ": log rec %u len %u " + ("scan " LSN_PF ": log rec %u len %u " "page %u:%u", old_lsn, (unsigned) type, (unsigned) len, (unsigned) space, (unsigned) page_no)); @@ -2531,7 +2531,7 @@ loop: #endif /* UNIV_LOG_DEBUG */ DBUG_PRINT("ib_log", - ("scan " DBUG_LSN_PF ": multi-log rec %u " + ("scan " LSN_PF ": multi-log rec %u " "len %u page %u:%u", recv_sys->recovered_lsn, (unsigned) type, (unsigned) len, diff --git a/storage/xtradb/row/row0import.cc b/storage/xtradb/row/row0import.cc index e1fef3d3716..23b9ba60269 100644 --- a/storage/xtradb/row/row0import.cc +++ b/storage/xtradb/row/row0import.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -573,8 +574,8 @@ AbstractCallback::init( } else if (!is_compressed_table() && m_page_size != UNIV_PAGE_SIZE) { ib_logf(IB_LOG_LEVEL_ERROR, - "Page size %lu of ibd file is not the same " - "as the server page size %lu", + "Page size " ULINTPF " of ibd file is not the same " + "as the server page size " ULINTPF, m_page_size, UNIV_PAGE_SIZE); return(DB_CORRUPTION); @@ -583,8 +584,8 @@ AbstractCallback::init( ib_logf(IB_LOG_LEVEL_ERROR, "File size " UINT64PF " is not a multiple " - "of the page size %lu", - (ib_uint64_t) file_size, (ulong) m_page_size); + "of the page size " ULINTPF, + (ib_uint64_t) file_size, m_page_size); return(DB_CORRUPTION); } @@ -725,8 +726,8 @@ FetchIndexRootPages::operator() ( if (block->page.offset * m_page_size != offset) { ib_logf(IB_LOG_LEVEL_ERROR, "Page offset doesn't match file offset: " - "page offset: %lu, file offset: %lu", - (ulint) block->page.offset, + "page offset: %u, file offset: " ULINTPF, + block->page.offset, (ulint) (offset / m_page_size)); err = DB_CORRUPTION; @@ -1159,10 +1160,9 @@ row_import::match_index_columns( ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Index field count %lu doesn't match" - " tablespace metadata file value %lu", - (ulong) index->n_fields, - (ulong) cfg_index->m_n_fields); + "Index field count %u doesn't match" + " tablespace metadata file value " ULINTPF, + index->n_fields, cfg_index->m_n_fields); return(DB_ERROR); } @@ -1179,34 +1179,31 @@ row_import::match_index_columns( ER_TABLE_SCHEMA_MISMATCH, "Index field name %s doesn't match" " tablespace metadata field name %s" - " for field position %lu", - field->name, cfg_field->name, (ulong) i); + " for field position " ULINTPF, + field->name, cfg_field->name, i); err = DB_ERROR; } if (cfg_field->prefix_len != field->prefix_len) { ib_errf(thd, IB_LOG_LEVEL_ERROR, - ER_TABLE_SCHEMA_MISMATCH, - "Index %s field %s prefix len %lu" - " doesn't match metadata file value" - " %lu", - index->name, field->name, - (ulong) field->prefix_len, - (ulong) cfg_field->prefix_len); + ER_TABLE_SCHEMA_MISMATCH, + "Index %s field %s prefix len %u" + " doesn't match metadata file value %u", + index->name, field->name, + field->prefix_len, cfg_field->prefix_len); err = DB_ERROR; } if (cfg_field->fixed_len != field->fixed_len) { ib_errf(thd, IB_LOG_LEVEL_ERROR, - ER_TABLE_SCHEMA_MISMATCH, - "Index %s field %s fixed len %lu" - " doesn't match metadata file value" - " %lu", - index->name, field->name, - (ulong) field->fixed_len, - (ulong) cfg_field->fixed_len); + ER_TABLE_SCHEMA_MISMATCH, + "Index %s field %s fixed len %u" + " doesn't match metadata file value %u", + index->name, field->name, + field->fixed_len, + cfg_field->fixed_len); err = DB_ERROR; } @@ -1248,12 +1245,11 @@ row_import::match_table_columns( } else if (cfg_col_index != col->ind) { ib_errf(thd, IB_LOG_LEVEL_ERROR, - ER_TABLE_SCHEMA_MISMATCH, - "Column %s ordinal value mismatch, it's at " - "%lu in the table and %lu in the tablespace " - "meta-data file", - col_name, - (ulong) col->ind, (ulong) cfg_col_index); + ER_TABLE_SCHEMA_MISMATCH, + "Column %s ordinal value mismatch, it's at %u" + " in the table and " ULINTPF + " in the tablespace meta-data file", + col_name, col->ind, cfg_col_index); err = DB_ERROR; } else { @@ -1335,23 +1331,20 @@ row_import::match_schema( THD* thd) UNIV_NOTHROW { /* Do some simple checks. */ - const unsigned relevant_flags = m_flags & ~DICT_TF_MASK_DATA_DIR; - const unsigned relevant_table_flags - = m_table->flags & ~DICT_TF_MASK_DATA_DIR; - if (relevant_flags != relevant_table_flags) { + if ((m_table->flags ^ m_flags) & ~DICT_TF_MASK_DATA_DIR) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Table flags don't match, server table has 0x%x " - "and the meta-data file has 0x%x", - relevant_table_flags, relevant_flags); + "Table flags don't match, server table has 0x%x" + " and the meta-data file has 0x%lx", + m_table->flags, ulong(m_flags)); return(DB_ERROR); } else if (m_table->n_cols != m_n_cols) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Number of columns don't match, table has %lu " - "columns but the tablespace meta-data file has " - "%lu columns", - (ulong) m_table->n_cols, (ulong) m_n_cols); + "Number of columns don't match, table has %u " + "columns but the tablespace meta-data file has " + ULINTPF " columns", + m_table->n_cols, m_n_cols); return(DB_ERROR); } else if (UT_LIST_GET_LEN(m_table->indexes) != m_n_indexes) { @@ -1361,11 +1354,10 @@ row_import::match_schema( table matching the IMPORT definition. */ ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Number of indexes don't match, table has %lu " - "indexes but the tablespace meta-data file has " - "%lu indexes", - (ulong) UT_LIST_GET_LEN(m_table->indexes), - (ulong) m_n_indexes); + "Number of indexes don't match, table has " ULINTPF + " indexes but the tablespace meta-data file has " + ULINTPF " indexes", + UT_LIST_GET_LEN(m_table->indexes), m_n_indexes); return(DB_ERROR); } @@ -1441,8 +1433,8 @@ row_import::set_root_by_heuristic() UNIV_NOTHROW table_name, sizeof(table_name), m_table->name, FALSE); ib_logf(IB_LOG_LEVEL_WARN, - "Table %s should have %lu indexes but the tablespace " - "has %lu indexes", + "Table %s should have " ULINTPF + " indexes but the tablespace has " ULINTPF " indexes", table_name, UT_LIST_GET_LEN(m_table->indexes), m_n_indexes); @@ -1680,9 +1672,10 @@ PageConverter::adjust_cluster_index_blob_column( ib_errf(m_trx->mysql_thd, IB_LOG_LEVEL_ERROR, ER_INNODB_INDEX_CORRUPT, - "Externally stored column(%lu) has a reference " - "length of %lu in the cluster index %s", - (ulong) i, (ulong) len, index_name); + "Externally stored column(" ULINTPF + ") has a reference length of " ULINTPF + " in the cluster index %s", + i, len, index_name); return(DB_CORRUPTION); } @@ -2043,7 +2036,8 @@ PageConverter::update_page( return(err); } - ib_logf(IB_LOG_LEVEL_WARN, "Unknown page type (%lu)", page_type); + ib_logf(IB_LOG_LEVEL_WARN, "Unknown page type (" ULINTPF ")", + page_type); return(DB_CORRUPTION); } @@ -2077,7 +2071,8 @@ PageConverter::validate( if (checksum != 0) { /* Checksum check passed in buf_page_is_corrupted(). */ ib_logf(IB_LOG_LEVEL_WARN, - "%s: Page %lu checksum %lu should be zero.", + "%s: Page %lu checksum " ULINTPF + " should be zero.", m_filepath, (ulong) (offset / m_page_size), checksum); } @@ -2391,11 +2386,10 @@ row_import_adjust_root_pages_of_secondary_indexes( ib_errf(trx->mysql_thd, IB_LOG_LEVEL_WARN, ER_INNODB_INDEX_CORRUPT, - "Index '%s' contains %lu entries, " - "should be %lu, you should recreate " + "Index '%s' contains " ULINTPF " entries, " + "should be " ULINTPF ", you should recreate " "this index.", index_name, - (ulong) purge.get_n_rows(), - (ulong) n_rows_in_table); + purge.get_n_rows(), n_rows_in_table); index->type |= DICT_CORRUPT; @@ -2746,7 +2740,7 @@ row_import_read_index_data( if (len > OS_FILE_MAX_PATH) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_INNODB_INDEX_CORRUPT, - "Index name length (%lu) is too long, " + "Index name length (" ULINTPF ") is too long, " "the meta-data is corrupt", len); return(DB_CORRUPTION); @@ -2827,8 +2821,8 @@ row_import_read_indexes( } else if (cfg->m_n_indexes > 1024) { // FIXME: What is the upper limit? */ ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR, - "Number of indexes in meta-data file is too high: %lu", - (ulong) cfg->m_n_indexes); + "Number of indexes in meta-data file is too high: " + ULINTPF, cfg->m_n_indexes); cfg->m_n_indexes = 0; return(DB_CORRUPTION); @@ -2926,8 +2920,8 @@ row_import_read_columns( if (len == 0 || len > 128) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR, - "Column name length %lu, is invalid", - (ulong) len); + "Column name length " ULINTPF ", is invalid", + len); return(DB_CORRUPTION); } @@ -3098,8 +3092,9 @@ row_import_read_v1( ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, "Tablespace to be imported has a different " "page size than this server. Server page size " - "is %lu, whereas tablespace page size is %lu", - UNIV_PAGE_SIZE, (ulong) cfg->m_page_size); + "is " ULINTPF ", whereas tablespace page size is " + ULINTPF, + UNIV_PAGE_SIZE, cfg->m_page_size); return(DB_ERROR); } @@ -3164,8 +3159,8 @@ row_import_read_meta_data( return(row_import_read_v1(file, thd, &cfg)); default: ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR, - "Unsupported meta-data version number (%lu), " - "file ignored", (ulong) cfg.m_version); + "Unsupported meta-data version number (" ULINTPF "), " + "file ignored", cfg.m_version); } return(DB_ERROR); diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index bcc37fb530c..5082aae15cf 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2014, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -96,7 +96,8 @@ row_merge_tuple_print( } ut_print_buf(f, dfield_get_data(field), len); if (len != field_len) { - fprintf(f, " (total %lu bytes)", field_len); + fprintf(f, " (total " ULINTPF " bytes)", + field_len); } } } @@ -789,9 +790,9 @@ row_merge_buf_write( ut_ad(b < &block[srv_sort_buf_size]); #ifdef UNIV_DEBUG if (row_merge_print_write) { - fprintf(stderr, "row_merge_buf_write %p,%d,%lu %lu", - (void*) b, of->fd, (ulong) of->offset, - (ulong) i); + fprintf(stderr, "row_merge_buf_write %p,%d," + ULINTPF " " ULINTPF, + (void*) b, of->fd, of->offset, i); row_merge_tuple_print(stderr, entry, n_fields); } #endif /* UNIV_DEBUG */ @@ -808,8 +809,8 @@ row_merge_buf_write( #endif /* UNIV_DEBUG_VALGRIND */ #ifdef UNIV_DEBUG if (row_merge_print_write) { - fprintf(stderr, "row_merge_buf_write %p,%d,%lu EOF\n", - (void*) b, of->fd, (ulong) of->offset); + fprintf(stderr, "row_merge_buf_write %p,%d," ULINTPF " EOF\n", + (void*) b, of->fd, of->offset); } #endif /* UNIV_DEBUG */ } @@ -865,15 +866,8 @@ row_merge_read( #ifdef UNIV_DEBUG if (row_merge_print_block_read) { - fprintf(stderr, "row_merge_read fd=%d ofs=%lu\n", - fd, (ulong) offset); - } -#endif /* UNIV_DEBUG */ - -#ifdef UNIV_DEBUG - if (row_merge_print_block_read) { - fprintf(stderr, "row_merge_read fd=%d ofs=%lu\n", - fd, (ulong) offset); + fprintf(stderr, "row_merge_read fd=%d ofs=" ULINTPF "\n", + fd, offset); } #endif /* UNIV_DEBUG */ @@ -916,8 +910,8 @@ row_merge_write( #ifdef UNIV_DEBUG if (row_merge_print_block_write) { - fprintf(stderr, "row_merge_write fd=%d ofs=%lu\n", - fd, (ulong) offset); + fprintf(stderr, "row_merge_write fd=%d ofs=" ULINTPF "\n", + fd, offset); } #endif /* UNIV_DEBUG */ @@ -965,9 +959,10 @@ row_merge_read_rec( *mrec = NULL; #ifdef UNIV_DEBUG if (row_merge_print_read) { - fprintf(stderr, "row_merge_read %p,%p,%d,%lu EOF\n", + fprintf(stderr, "row_merge_read %p,%p,%d," ULINTPF + " EOF\n", (const void*) b, (const void*) block, - fd, (ulong) *foffs); + fd, *foffs); } #endif /* UNIV_DEBUG */ return(NULL); @@ -1082,9 +1077,9 @@ err_exit: func_exit: #ifdef UNIV_DEBUG if (row_merge_print_read) { - fprintf(stderr, "row_merge_read %p,%p,%d,%lu ", + fprintf(stderr, "row_merge_read %p,%p,%d," ULINTPF " ", (const void*) b, (const void*) block, - fd, (ulong) *foffs); + fd, *foffs); rec_print_comp(stderr, *mrec, offsets); putc('\n', stderr); } @@ -1118,8 +1113,8 @@ row_merge_write_rec_low( ut_ad(e == rec_offs_extra_size(offsets) + 1); if (row_merge_print_write) { - fprintf(stderr, "row_merge_write %p,%d,%lu ", - (void*) b, fd, (ulong) foffs); + fprintf(stderr, "row_merge_write %p,%d," ULINTPF " ", + (void*) b, fd, foffs); rec_print_comp(stderr, mrec, offsets); putc('\n', stderr); } @@ -1221,8 +1216,8 @@ row_merge_write_eof( ut_ad(foffs); #ifdef UNIV_DEBUG if (row_merge_print_write) { - fprintf(stderr, "row_merge_write %p,%p,%d,%lu EOF\n", - (void*) b, (void*) block, fd, (ulong) *foffs); + fprintf(stderr, "row_merge_write %p,%p,%d," ULINTPF " EOF\n", + (void*) b, (void*) block, fd, *foffs); } #endif /* UNIV_DEBUG */ @@ -2067,11 +2062,12 @@ row_merge_blocks( #ifdef UNIV_DEBUG if (row_merge_print_block) { fprintf(stderr, - "row_merge_blocks fd=%d ofs=%lu + fd=%d ofs=%lu" - " = fd=%d ofs=%lu\n", - file->fd, (ulong) *foffs0, - file->fd, (ulong) *foffs1, - of->fd, (ulong) of->offset); + "row_merge_blocks fd=%d ofs=" ULINTPF + " + fd=%d ofs=" ULINTPF + " = fd=%d ofs=" ULINTPF "\n", + file->fd, *foffs0, + file->fd, *foffs1, + of->fd, of->offset); } #endif /* UNIV_DEBUG */ @@ -2170,10 +2166,10 @@ row_merge_blocks_copy( #ifdef UNIV_DEBUG if (row_merge_print_block) { fprintf(stderr, - "row_merge_blocks_copy fd=%d ofs=%lu" - " = fd=%d ofs=%lu\n", - file->fd, (ulong) foffs0, - of->fd, (ulong) of->offset); + "row_merge_blocks_copy fd=%d ofs=" ULINTPF + " = fd=%d ofs=" ULINTPF "\n", + file->fd, *foffs0, + of->fd, of->offset); } #endif /* UNIV_DEBUG */ From 3a6af51a8adc1e7a7b94534dbf26bdcad836f3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Apr 2017 05:05:51 +0300 Subject: [PATCH 43/52] Do not crash XtraDB when fil_space_acquire() fails This reverts part of commit 50eb40a2a8aa3af6cc271f6028f4d6d74301d030 which backported the code from MariaDB 10.2. The XtraDB version of the code included a ut_error statement (aborting the process) when a tablespace is not found. Luckily this change was not part of a release; MariaDB 10.1.22 had been released some days earlier. --- storage/xtradb/fil/fil0fil.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index e7244d719c8..43788012920 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -7401,7 +7401,6 @@ fil_space_acquire_low(ulint id, bool silent, bool for_io = false) if (!silent) { ib_logf(IB_LOG_LEVEL_WARN, "Trying to access missing" " tablespace " ULINTPF ".", id); - ut_error; } } else if (!for_io && space->is_stopping()) { space = NULL; From e48ae21b0ea99a3d3cc16eebd414cc484fa4f38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Apr 2017 16:22:46 +0300 Subject: [PATCH 44/52] Follow-up to MDEV-12534: Fix warnings on 32-bit systems --- storage/innobase/os/os0file.cc | 4 ++-- storage/innobase/srv/srv0srv.cc | 4 ++-- storage/xtradb/os/os0file.cc | 4 ++-- storage/xtradb/srv/srv0srv.cc | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index ff67c90eecf..d8cb44217bb 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -5647,8 +5647,8 @@ os_aio_print( os_n_file_writes, os_n_fsyncs); - const ulint n_reads = MONITOR_VALUE(MONITOR_OS_PENDING_READS); - const ulint n_writes = MONITOR_VALUE(MONITOR_OS_PENDING_WRITES); + const ulint n_reads = ulint(MONITOR_VALUE(MONITOR_OS_PENDING_READS)); + const ulint n_writes = ulint(MONITOR_VALUE(MONITOR_OS_PENDING_WRITES)); if (n_reads != 0 || n_writes != 0) { fprintf(file, diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 58e69c3c9e7..067e32a83aa 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1409,10 +1409,10 @@ srv_export_innodb_status(void) mutex_enter(&srv_innodb_monitor_mutex); export_vars.innodb_data_pending_reads = - MONITOR_VALUE(MONITOR_OS_PENDING_READS); + ulint(MONITOR_VALUE(MONITOR_OS_PENDING_READS)); export_vars.innodb_data_pending_writes = - MONITOR_VALUE(MONITOR_OS_PENDING_WRITES); + ulint(MONITOR_VALUE(MONITOR_OS_PENDING_WRITES)); export_vars.innodb_data_pending_fsyncs = fil_n_pending_log_flushes diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc index 48ae49f28e4..9632bb77df9 100644 --- a/storage/xtradb/os/os0file.cc +++ b/storage/xtradb/os/os0file.cc @@ -5820,8 +5820,8 @@ os_aio_print( os_n_file_writes, os_n_fsyncs); - const ulint n_reads = MONITOR_VALUE(MONITOR_OS_PENDING_READS); - const ulint n_writes = MONITOR_VALUE(MONITOR_OS_PENDING_WRITES); + const ulint n_reads = ulint(MONITOR_VALUE(MONITOR_OS_PENDING_READS)); + const ulint n_writes = ulint(MONITOR_VALUE(MONITOR_OS_PENDING_WRITES)); if (n_reads != 0 || n_writes != 0) { fprintf(file, diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc index c47119e63cf..5b3f86d8641 100644 --- a/storage/xtradb/srv/srv0srv.cc +++ b/storage/xtradb/srv/srv0srv.cc @@ -1735,10 +1735,10 @@ srv_export_innodb_status(void) mutex_enter(&srv_innodb_monitor_mutex); export_vars.innodb_data_pending_reads = - MONITOR_VALUE(MONITOR_OS_PENDING_READS); + ulint(MONITOR_VALUE(MONITOR_OS_PENDING_READS)); export_vars.innodb_data_pending_writes = - MONITOR_VALUE(MONITOR_OS_PENDING_WRITES); + ulint(MONITOR_VALUE(MONITOR_OS_PENDING_WRITES)); export_vars.innodb_data_pending_fsyncs = fil_n_pending_log_flushes From e056d1f1ca91ebe40467ed46be00be0add9cf247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Apr 2017 17:39:12 +0300 Subject: [PATCH 45/52] Fix some InnoDB type mismatch On 64-bit Windows, sizeof(ulint)!=sizeof(ulong). --- storage/innobase/buf/buf0buf.cc | 25 ++++++++++++------------- storage/innobase/row/row0ftsort.cc | 7 +++---- storage/xtradb/buf/buf0buf.cc | 25 ++++++++++++------------- storage/xtradb/row/row0ftsort.cc | 7 +++---- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 73d061c4b20..0b305507271 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -5311,23 +5311,22 @@ buf_print_io_instance( pool_info->pages_written_rate); if (pool_info->n_page_get_delta) { - double hit_rate = ((1000 * pool_info->page_read_delta) - / pool_info->n_page_get_delta); + double hit_rate = double(pool_info->page_read_delta) + / pool_info->n_page_get_delta; - if (hit_rate > 1000) { - hit_rate = 1000; + if (hit_rate > 1) { + hit_rate = 1; } - hit_rate = 1000 - hit_rate; - fprintf(file, - "Buffer pool hit rate %lu / 1000," - " young-making rate %lu / 1000 not %lu / 1000\n", - (ulint) hit_rate, - (ulint) (1000 * pool_info->young_making_delta - / pool_info->n_page_get_delta), - (ulint) (1000 * pool_info->not_young_making_delta - / pool_info->n_page_get_delta)); + "Buffer pool hit rate " ULINTPF " / 1000," + " young-making rate " ULINTPF " / 1000 not " + ULINTPF " / 1000\n", + ulint(1000 * (1 - hit_rate)), + ulint(1000 * double(pool_info->young_making_delta) + / pool_info->n_page_get_delta), + ulint(1000 * double(pool_info->not_young_making_delta) + / pool_info->n_page_get_delta)); } else { fputs("No buffer pool page gets since the last printout\n", file); diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 4865c8e850a..5b8ed009a2a 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1248,10 +1248,9 @@ row_fts_build_sel_tree_level( int child_left; int child_right; ulint i; - ulint num_item; + ulint num_item = ulint(1) << level; - start = static_cast((1 << level) - 1); - num_item = static_cast(1 << level); + start = num_item - 1; for (i = 0; i < num_item; i++) { child_left = sel_tree[(start + i) * 2 + 1]; @@ -1320,7 +1319,7 @@ row_fts_build_sel_tree( treelevel++; } - start = (1 << treelevel) - 1; + start = (ulint(1) << treelevel) - 1; for (i = 0; i < (int) fts_sort_pll_degree; i++) { sel_tree[i + start] = i; diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index a5d8b661c35..07b84c60c76 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -5593,23 +5593,22 @@ buf_print_io_instance( pool_info->pages_written_rate); if (pool_info->n_page_get_delta) { - double hit_rate = ((1000 * pool_info->page_read_delta) - / pool_info->n_page_get_delta); + double hit_rate = double(pool_info->page_read_delta) + / pool_info->n_page_get_delta; - if (hit_rate > 1000) { - hit_rate = 1000; + if (hit_rate > 1) { + hit_rate = 1; } - hit_rate = 1000 - hit_rate; - fprintf(file, - "Buffer pool hit rate %lu / 1000," - " young-making rate %lu / 1000 not %lu / 1000\n", - (ulint) hit_rate, - (ulint) (1000 * pool_info->young_making_delta - / pool_info->n_page_get_delta), - (ulint) (1000 * pool_info->not_young_making_delta - / pool_info->n_page_get_delta)); + "Buffer pool hit rate " ULINTPF " / 1000," + " young-making rate " ULINTPF " / 1000 not " + ULINTPF " / 1000\n", + ulint(1000 * (1 - hit_rate)), + ulint(1000 * double(pool_info->young_making_delta) + / pool_info->n_page_get_delta), + ulint(1000 * double(pool_info->not_young_making_delta) + / pool_info->n_page_get_delta)); } else { fputs("No buffer pool page gets since the last printout\n", file); diff --git a/storage/xtradb/row/row0ftsort.cc b/storage/xtradb/row/row0ftsort.cc index 134127c6adf..13877b8fe08 100644 --- a/storage/xtradb/row/row0ftsort.cc +++ b/storage/xtradb/row/row0ftsort.cc @@ -1251,10 +1251,9 @@ row_fts_build_sel_tree_level( int child_left; int child_right; ulint i; - ulint num_item; + ulint num_item = ulint(1) << level; - start = static_cast((1 << level) - 1); - num_item = static_cast(1 << level); + start = num_item - 1; for (i = 0; i < num_item; i++) { child_left = sel_tree[(start + i) * 2 + 1]; @@ -1323,7 +1322,7 @@ row_fts_build_sel_tree( treelevel++; } - start = (1 << treelevel) - 1; + start = (ulint(1) << treelevel) - 1; for (i = 0; i < (int) fts_sort_pll_degree; i++) { sel_tree[i + start] = i; From aafaf05a47221e035039d75a8f62dbda2379d044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Apr 2017 08:45:48 +0300 Subject: [PATCH 46/52] Fix some InnoDB type mismatch introduced in 10.1 On 64-bit Windows, sizeof(ulint)!=sizeof(ulong). --- storage/innobase/buf/buf0buf.cc | 17 +++++++---------- storage/innobase/buf/buf0dblwr.cc | 4 ++-- storage/innobase/fil/fil0crypt.cc | 23 +++++++++++++---------- storage/innobase/fil/fil0fil.cc | 3 ++- storage/innobase/fil/fil0pagecompress.cc | 5 +++-- storage/xtradb/buf/buf0buf.cc | 17 +++++++---------- storage/xtradb/buf/buf0dblwr.cc | 4 ++-- storage/xtradb/fil/fil0crypt.cc | 23 +++++++++++++---------- storage/xtradb/fil/fil0fil.cc | 3 ++- storage/xtradb/fil/fil0pagecompress.cc | 5 +++-- 10 files changed, 54 insertions(+), 50 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 89924dd3675..2133457fcbb 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -6269,9 +6269,9 @@ buf_page_decrypt_after_read( /* decompress using comp_buf to dst_frame */ fil_decompress_page(slot->comp_buf, - dst_frame, - size, - &bpage->write_size); + dst_frame, + ulong(size), + &bpage->write_size); /* Mark this slot as free */ slot->reserved = false; @@ -6323,13 +6323,10 @@ buf_page_decrypt_after_read( #endif /* decompress using comp_buf to dst_frame */ fil_decompress_page(slot->comp_buf, - dst_frame, - size, - &bpage->write_size); - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif + dst_frame, + ulong(size), + &bpage->write_size); + ut_d(fil_page_type_validate(dst_frame)); } /* Mark this slot as free */ diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 2e0cbc1a8b2..f99679f6fec 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -538,7 +538,7 @@ buf_dblwr_process() /* Decompress the page before validating the checksum. */ fil_decompress_page( - NULL, read_buf, UNIV_PAGE_SIZE, + NULL, read_buf, srv_page_size, NULL, true); } @@ -565,7 +565,7 @@ buf_dblwr_process() /* Decompress the page before validating the checksum. */ fil_decompress_page( - NULL, page, UNIV_PAGE_SIZE, NULL, true); + NULL, page, srv_page_size, NULL, true); } if (!fil_space_verify_crypt_checksum(page, zip_size, NULL, page_no) diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 9c5f782da32..b8892b4ec31 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -694,7 +694,8 @@ fil_space_encrypt( comp_mem = (byte *)malloc(UNIV_PAGE_SIZE); uncomp_mem = (byte *)malloc(UNIV_PAGE_SIZE); memcpy(comp_mem, src_frame, UNIV_PAGE_SIZE); - fil_decompress_page(uncomp_mem, comp_mem, UNIV_PAGE_SIZE, NULL); + fil_decompress_page(uncomp_mem, comp_mem, + srv_page_size, NULL); src = uncomp_mem; } @@ -704,7 +705,8 @@ fil_space_encrypt( /* Need to decompress the page if it was also compressed */ if (page_compressed_encrypted) { memcpy(comp_mem, tmp_mem, UNIV_PAGE_SIZE); - fil_decompress_page(tmp_mem, comp_mem, UNIV_PAGE_SIZE, NULL); + fil_decompress_page(tmp_mem, comp_mem, + srv_page_size, NULL); } bool corrupted = buf_page_is_corrupted(true, tmp_mem, zip_size, space); @@ -1492,20 +1494,21 @@ fil_crypt_realloc_iops( if (10 * state->cnt_waited > state->batch) { /* if we waited more than 10% re-estimate max_iops */ - uint avg_wait_time_us = + ulint avg_wait_time_us = state->sum_waited_us / state->cnt_waited; - DBUG_PRINT("ib_crypt", - ("thr_no: %u - update estimated_max_iops from %u to %u.", - state->thread_no, - state->estimated_max_iops, - 1000000 / avg_wait_time_us)); - if (avg_wait_time_us == 0) { avg_wait_time_us = 1; // prevent division by zero } - state->estimated_max_iops = 1000000 / avg_wait_time_us; + DBUG_PRINT("ib_crypt", + ("thr_no: %u - update estimated_max_iops from %u to " + ULINTPF ".", + state->thread_no, + state->estimated_max_iops, + 1000000 / avg_wait_time_us)); + + state->estimated_max_iops = uint(1000000 / avg_wait_time_us); state->cnt_waited = 0; state->sum_waited_us = 0; } else { diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 6fec41839ee..ceda86e16b6 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -6708,7 +6708,8 @@ fil_iterate( /* If the original page is page_compressed, we need to decompress page before we can update it. */ if (page_compressed) { - fil_decompress_page(NULL, dst, size, NULL); + fil_decompress_page(NULL, dst, ulong(size), + NULL); updated = true; } diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index bfc054701a4..42f894f08d7 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -300,7 +300,8 @@ fil_compress_page( #endif /* HAVE_SNAPPY */ case PAGE_ZLIB_ALGORITHM: - err = compress2(out_buf+header_len, (ulong*)&write_size, buf, len, comp_level); + err = compress2(out_buf+header_len, (ulong*)&write_size, buf, + uLong(len), comp_level); if (err != Z_OK) { /* If error we leave the actual page as it was */ @@ -364,7 +365,7 @@ fil_compress_page( uncomp_page = static_cast(ut_malloc(UNIV_PAGE_SIZE)); memcpy(comp_page, out_buf, UNIV_PAGE_SIZE); - fil_decompress_page(uncomp_page, comp_page, len, NULL); + fil_decompress_page(uncomp_page, comp_page, ulong(len), NULL); if(buf_page_is_corrupted(false, uncomp_page, 0, space)) { buf_page_print(uncomp_page, 0, BUF_PAGE_PRINT_NO_CRASH); diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 3fe07800fd3..7f77f96c2fe 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -6429,9 +6429,9 @@ buf_page_decrypt_after_read( /* decompress using comp_buf to dst_frame */ fil_decompress_page(slot->comp_buf, - dst_frame, - size, - &bpage->write_size); + dst_frame, + ulong(size), + &bpage->write_size); /* Mark this slot as free */ slot->reserved = false; @@ -6483,13 +6483,10 @@ buf_page_decrypt_after_read( #endif /* decompress using comp_buf to dst_frame */ fil_decompress_page(slot->comp_buf, - dst_frame, - size, - &bpage->write_size); - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif + dst_frame, + ulong(size), + &bpage->write_size); + ut_d(fil_page_type_validate(dst_frame)); } /* Mark this slot as free */ diff --git a/storage/xtradb/buf/buf0dblwr.cc b/storage/xtradb/buf/buf0dblwr.cc index b11c32064bf..ddef13ef8ea 100644 --- a/storage/xtradb/buf/buf0dblwr.cc +++ b/storage/xtradb/buf/buf0dblwr.cc @@ -538,7 +538,7 @@ buf_dblwr_process() /* Decompress the page before validating the checksum. */ fil_decompress_page( - NULL, read_buf, UNIV_PAGE_SIZE, + NULL, read_buf, srv_page_size, NULL, true); } @@ -565,7 +565,7 @@ buf_dblwr_process() /* Decompress the page before validating the checksum. */ fil_decompress_page( - NULL, page, UNIV_PAGE_SIZE, NULL, true); + NULL, page, srv_page_size, NULL, true); } if (!fil_space_verify_crypt_checksum(page, zip_size, NULL, page_no) diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index 9c5f782da32..b8892b4ec31 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -694,7 +694,8 @@ fil_space_encrypt( comp_mem = (byte *)malloc(UNIV_PAGE_SIZE); uncomp_mem = (byte *)malloc(UNIV_PAGE_SIZE); memcpy(comp_mem, src_frame, UNIV_PAGE_SIZE); - fil_decompress_page(uncomp_mem, comp_mem, UNIV_PAGE_SIZE, NULL); + fil_decompress_page(uncomp_mem, comp_mem, + srv_page_size, NULL); src = uncomp_mem; } @@ -704,7 +705,8 @@ fil_space_encrypt( /* Need to decompress the page if it was also compressed */ if (page_compressed_encrypted) { memcpy(comp_mem, tmp_mem, UNIV_PAGE_SIZE); - fil_decompress_page(tmp_mem, comp_mem, UNIV_PAGE_SIZE, NULL); + fil_decompress_page(tmp_mem, comp_mem, + srv_page_size, NULL); } bool corrupted = buf_page_is_corrupted(true, tmp_mem, zip_size, space); @@ -1492,20 +1494,21 @@ fil_crypt_realloc_iops( if (10 * state->cnt_waited > state->batch) { /* if we waited more than 10% re-estimate max_iops */ - uint avg_wait_time_us = + ulint avg_wait_time_us = state->sum_waited_us / state->cnt_waited; - DBUG_PRINT("ib_crypt", - ("thr_no: %u - update estimated_max_iops from %u to %u.", - state->thread_no, - state->estimated_max_iops, - 1000000 / avg_wait_time_us)); - if (avg_wait_time_us == 0) { avg_wait_time_us = 1; // prevent division by zero } - state->estimated_max_iops = 1000000 / avg_wait_time_us; + DBUG_PRINT("ib_crypt", + ("thr_no: %u - update estimated_max_iops from %u to " + ULINTPF ".", + state->thread_no, + state->estimated_max_iops, + 1000000 / avg_wait_time_us)); + + state->estimated_max_iops = uint(1000000 / avg_wait_time_us); state->cnt_waited = 0; state->sum_waited_us = 0; } else { diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index 43788012920..fba7d5d8e38 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -6772,7 +6772,8 @@ fil_iterate( /* If the original page is page_compressed, we need to decompress page before we can update it. */ if (page_compressed) { - fil_decompress_page(NULL, dst, size, NULL); + fil_decompress_page(NULL, dst, ulong(size), + NULL); updated = true; } diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index 303ab5102fb..655460c57ac 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -300,7 +300,8 @@ fil_compress_page( #endif /* HAVE_SNAPPY */ case PAGE_ZLIB_ALGORITHM: - err = compress2(out_buf+header_len, (ulong*)&write_size, buf, len, comp_level); + err = compress2(out_buf+header_len, (ulong*)&write_size, buf, + uLong(len), comp_level); if (err != Z_OK) { /* If error we leave the actual page as it was */ @@ -364,7 +365,7 @@ fil_compress_page( uncomp_page = static_cast(ut_malloc(UNIV_PAGE_SIZE)); memcpy(comp_page, out_buf, UNIV_PAGE_SIZE); - fil_decompress_page(uncomp_page, comp_page, len, NULL); + fil_decompress_page(uncomp_page, comp_page, ulong(len), NULL); if(buf_page_is_corrupted(false, uncomp_page, 0, space)) { buf_page_print(uncomp_page, 0, BUF_PAGE_PRINT_NO_CRASH); From d23eb8e6d27dfc6450465baa2897db5ebd334ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Apr 2017 16:06:05 +0300 Subject: [PATCH 47/52] Follow-up to MDEV-12488: Fix some type mismatch in header files This reduces the number of compilation warnings on Windows. --- storage/innobase/include/dict0dict.ic | 99 +++++++++++++++---------- storage/innobase/include/fil0crypt.h | 6 +- storage/innobase/include/fil0fil.ic | 37 ++++------ storage/xtradb/include/dict0dict.ic | 101 +++++++++++++++----------- storage/xtradb/include/fil0crypt.h | 6 +- storage/xtradb/include/fil0fil.ic | 38 ++++------ 6 files changed, 151 insertions(+), 136 deletions(-) diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index dafc36f1cab..cf5a6a22d65 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -541,13 +541,15 @@ dict_tf_is_valid( /* Make sure there are no bits that we do not know about. */ if (unused != 0) { fprintf(stderr, - "InnoDB: Error: table unused flags are %ld" + "InnoDB: Error: table unused flags are " ULINTPF " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF " atomic_blobs " ULINTPF + "\nInnoDB: unused " ULINTPF " data_dir " ULINTPF + " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", unused, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes @@ -563,13 +565,17 @@ dict_tf_is_valid( if (!compact) { fprintf(stderr, - "InnoDB: Error: table compact flags are %ld" + "InnoDB: Error: table compact flags are " + ULINTPF " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF + " atomic_blobs " ULINTPF "\n" + "InnoDB: unused " ULINTPF + " data_dir " ULINTPF " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", compact, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes ); @@ -580,13 +586,15 @@ dict_tf_is_valid( /* Antelope does not support COMPRESSED row format. */ fprintf(stderr, - "InnoDB: Error: table flags are %ld" + "InnoDB: Error: table flags are " ULINTPF " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF " atomic_blobs " ULINTPF + "\nInnoDB: unused " ULINTPF " data_dir " ULINTPF + " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", flags, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes ); @@ -603,12 +611,17 @@ dict_tf_is_valid( || zip_ssize > PAGE_ZIP_SSIZE_MAX) { fprintf(stderr, - "InnoDB: Error: table compact flags are %ld in the data dictionary and are corrupted\n" + "InnoDB: Error: table compact flags are " + ULINTPF + " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF + " atomic_blobs " ULINTPF "\n" + "InnoDB: unused " ULINTPF + " data_dir " ULINTPF " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", flags, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes @@ -627,12 +640,16 @@ dict_tf_is_valid( || !atomic_blobs) { fprintf(stderr, - "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n" + "InnoDB: Error: table flags are " ULINTPF + " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF + " atomic_blobs " ULINTPF "\n" + "InnoDB: unused " ULINTPF + " data_dir " ULINTPF " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", flags, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes ); @@ -645,12 +662,16 @@ dict_tf_is_valid( if(atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, - "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n" + "InnoDB: Error: table flags are " ULINTPF + " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF + " atomic_blobs " ULINTPF "\n" + "InnoDB: unused " ULINTPF + " data_dir " ULINTPF " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", flags, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes ); @@ -695,7 +716,7 @@ dict_sys_tables_type_validate( if (redundant) { if (zip_ssize || atomic_blobs) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=Redundant, zip_ssize %lu atomic_blobs %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=Redundant, zip_ssize " ULINTPF " atomic_blobs " ULINTPF "\n", zip_ssize, atomic_blobs); return(ULINT_UNDEFINED); } @@ -703,7 +724,7 @@ dict_sys_tables_type_validate( /* Make sure there are no bits that we do not know about. */ if (unused) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, unused %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", unused " ULINTPF "\n", type, unused); return(ULINT_UNDEFINED); } @@ -719,7 +740,7 @@ dict_sys_tables_type_validate( } else if (zip_ssize) { /* Antelope does not support COMPRESSED format. */ - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, zip_ssize %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", zip_ssize " ULINTPF "\n", type, zip_ssize); return(ULINT_UNDEFINED); } @@ -730,14 +751,14 @@ dict_sys_tables_type_validate( should be in N_COLS, but we already know about the low_order_bit and DICT_N_COLS_COMPACT flags. */ if (!atomic_blobs) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, zip_ssize %lu atomic_blobs %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", zip_ssize " ULINTPF " atomic_blobs " ULINTPF "\n", type, zip_ssize, atomic_blobs); return(ULINT_UNDEFINED); } /* Validate that the number is within allowed range. */ if (zip_ssize > PAGE_ZIP_SSIZE_MAX) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, zip_ssize %lu max %d\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", zip_ssize " ULINTPF " max %d\n", type, zip_ssize, PAGE_ZIP_SSIZE_MAX); return(ULINT_UNDEFINED); } @@ -755,8 +776,8 @@ dict_sys_tables_type_validate( low_order_bit and DICT_N_COLS_COMPACT flags. */ if (!atomic_blobs || !page_compression) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, page_compression %lu page_compression_level %lu\n" - "InnoDB: Error: atomic_blobs %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", page_compression " ULINTPF " page_compression_level " ULINTPF "\n" + "InnoDB: Error: atomic_blobs " ULINTPF "\n", type, page_compression, page_compression_level, atomic_blobs); return(ULINT_UNDEFINED); } @@ -764,7 +785,7 @@ dict_sys_tables_type_validate( /* Validate that the atomic writes number is within allowed range. */ if (atomic_writes > ATOMIC_WRITES_OFF) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, atomic_writes %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", atomic_writes " ULINTPF "\n", type, atomic_writes); return(ULINT_UNDEFINED); } diff --git a/storage/innobase/include/fil0crypt.h b/storage/innobase/include/fil0crypt.h index cfc2d850883..e7e9676aa3a 100644 --- a/storage/innobase/include/fil0crypt.h +++ b/storage/innobase/include/fil0crypt.h @@ -109,7 +109,7 @@ struct fil_space_crypt_t : st_encryption_scheme The object is expected to be placed in a buffer that has been zero-initialized. */ fil_space_crypt_t( - ulint new_type, + uint new_type, uint new_min_key_version, uint new_key_id, fil_encryption_t new_encryption) @@ -117,10 +117,10 @@ struct fil_space_crypt_t : st_encryption_scheme min_key_version(new_min_key_version), page0_offset(0), encryption(new_encryption), - key_found(), + mutex(), + key_found(new_min_key_version), rotate_state() { - key_found = new_min_key_version; key_id = new_key_id; my_random_bytes(iv, sizeof(iv)); mutex_create(fil_crypt_data_mutex_key, diff --git a/storage/innobase/include/fil0fil.ic b/storage/innobase/include/fil0fil.ic index bea274d2c86..b79167baead 100644 --- a/storage/innobase/include/fil0fil.ic +++ b/storage/innobase/include/fil0fil.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2015, MariaDB Corporation. +Copyright (c) 2015, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -137,7 +137,7 @@ fil_page_type_validate( page_type == FIL_PAGE_TYPE_ZBLOB2 || page_type == FIL_PAGE_TYPE_COMPRESSED))) { - uint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); + ulint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED); bool page_compressed_encrypted = (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); ulint space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); @@ -149,28 +149,17 @@ fil_page_type_validate( fil_system_exit(); /* Dump out the page info */ - fprintf(stderr, "InnoDB: Space %lu offset %lu name %s page_type %lu page_type_name %s\n" - "InnoDB: key_version %u page_compressed %d page_compressed_encrypted %d lsn %llu compressed_len %lu\n", - space, offset, rspace->name, page_type, fil_get_page_type_name(page_type), - key_version, page_compressed, page_compressed_encrypted, (ulonglong)lsn, compressed_len); - fflush(stderr); - - ut_ad(page_type == FIL_PAGE_PAGE_COMPRESSED || - page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED || - page_type == FIL_PAGE_INDEX || - page_type == FIL_PAGE_UNDO_LOG || - page_type == FIL_PAGE_INODE || - page_type == FIL_PAGE_IBUF_FREE_LIST || - page_type == FIL_PAGE_TYPE_ALLOCATED || - page_type == FIL_PAGE_IBUF_BITMAP || - page_type == FIL_PAGE_TYPE_SYS || - page_type == FIL_PAGE_TYPE_TRX_SYS || - page_type == FIL_PAGE_TYPE_FSP_HDR || - page_type == FIL_PAGE_TYPE_XDES || - page_type == FIL_PAGE_TYPE_BLOB || - page_type == FIL_PAGE_TYPE_ZBLOB || - page_type == FIL_PAGE_TYPE_ZBLOB2 || - page_type == FIL_PAGE_TYPE_COMPRESSED); + fprintf(stderr, "InnoDB: Page " ULINTPF ":" ULINTPF + " name %s page_type " ULINTPF " page_type_name %s\n" + "InnoDB: key_version " ULINTPF + " page_compressed %d page_compressed_encrypted %d lsn " + LSN_PF " compressed_len " ULINTPF "\n", + space, offset, rspace->name, page_type, + fil_get_page_type_name(page_type), + key_version, + page_compressed, page_compressed_encrypted, + lsn, compressed_len); + ut_error; return false; } diff --git a/storage/xtradb/include/dict0dict.ic b/storage/xtradb/include/dict0dict.ic index 81da2fa5580..e3de7a33123 100644 --- a/storage/xtradb/include/dict0dict.ic +++ b/storage/xtradb/include/dict0dict.ic @@ -540,15 +540,16 @@ dict_tf_is_valid( /* Make sure there are no bits that we do not know about. */ if (unused != 0) { - fprintf(stderr, - "InnoDB: Error: table unused flags are %ld" + "InnoDB: Error: table unused flags are " ULINTPF " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF " atomic_blobs " ULINTPF + "\nInnoDB: unused " ULINTPF " data_dir " ULINTPF + " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", unused, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes @@ -564,17 +565,20 @@ dict_tf_is_valid( if (!compact) { fprintf(stderr, - "InnoDB: Error: table compact flags are %ld" + "InnoDB: Error: table compact flags are " + ULINTPF " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF + " atomic_blobs " ULINTPF "\n" + "InnoDB: unused " ULINTPF + " data_dir " ULINTPF " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", compact, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes ); - return(false); } @@ -582,17 +586,18 @@ dict_tf_is_valid( /* Antelope does not support COMPRESSED row format. */ fprintf(stderr, - "InnoDB: Error: table flags are %ld" + "InnoDB: Error: table flags are " ULINTPF " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF " atomic_blobs " ULINTPF + "\nInnoDB: unused " ULINTPF " data_dir " ULINTPF + " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", flags, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes ); - return(false); } @@ -606,12 +611,17 @@ dict_tf_is_valid( || zip_ssize > PAGE_ZIP_SSIZE_MAX) { fprintf(stderr, - "InnoDB: Error: table compact flags are %ld in the data dictionary and are corrupted\n" + "InnoDB: Error: table compact flags are " + ULINTPF + " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF + " atomic_blobs " ULINTPF "\n" + "InnoDB: unused " ULINTPF + " data_dir " ULINTPF " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", flags, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes @@ -630,16 +640,19 @@ dict_tf_is_valid( || !atomic_blobs) { fprintf(stderr, - "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n" + "InnoDB: Error: table flags are " ULINTPF + " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF + " atomic_blobs " ULINTPF "\n" + "InnoDB: unused " ULINTPF + " data_dir " ULINTPF " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", flags, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes ); - return(false); } } @@ -649,12 +662,16 @@ dict_tf_is_valid( if(atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, - "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n" + "InnoDB: Error: table flags are " ULINTPF + " in the data dictionary and are corrupted\n" "InnoDB: Error: data dictionary flags are\n" - "InnoDB: compact %ld atomic_blobs %ld\n" - "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n" - "InnoDB: page_compression %ld page_compression_level %ld\n" - "InnoDB: atomic_writes %ld\n", + "InnoDB: compact " ULINTPF + " atomic_blobs " ULINTPF "\n" + "InnoDB: unused " ULINTPF + " data_dir " ULINTPF " zip_ssize " ULINTPF + "\nInnoDB: page_compression " ULINTPF + " page_compression_level " ULINTPF + "\nInnoDB: atomic_writes " ULINTPF "\n", flags, compact, atomic_blobs, unused, data_dir, zip_ssize, page_compression, page_compression_level, atomic_writes ); @@ -699,7 +716,7 @@ dict_sys_tables_type_validate( if (redundant) { if (zip_ssize || atomic_blobs) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=Redundant, zip_ssize %lu atomic_blobs %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=Redundant, zip_ssize " ULINTPF " atomic_blobs " ULINTPF "\n", zip_ssize, atomic_blobs); return(ULINT_UNDEFINED); } @@ -707,7 +724,7 @@ dict_sys_tables_type_validate( /* Make sure there are no bits that we do not know about. */ if (unused) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, unused %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", unused " ULINTPF "\n", type, unused); return(ULINT_UNDEFINED); } @@ -723,7 +740,7 @@ dict_sys_tables_type_validate( } else if (zip_ssize) { /* Antelope does not support COMPRESSED format. */ - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, zip_ssize %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", zip_ssize " ULINTPF "\n", type, zip_ssize); return(ULINT_UNDEFINED); } @@ -734,14 +751,14 @@ dict_sys_tables_type_validate( should be in N_COLS, but we already know about the low_order_bit and DICT_N_COLS_COMPACT flags. */ if (!atomic_blobs) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, zip_ssize %lu atomic_blobs %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", zip_ssize " ULINTPF " atomic_blobs " ULINTPF "\n", type, zip_ssize, atomic_blobs); return(ULINT_UNDEFINED); } /* Validate that the number is within allowed range. */ if (zip_ssize > PAGE_ZIP_SSIZE_MAX) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, zip_ssize %lu max %d\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", zip_ssize " ULINTPF " max %d\n", type, zip_ssize, PAGE_ZIP_SSIZE_MAX); return(ULINT_UNDEFINED); } @@ -759,8 +776,8 @@ dict_sys_tables_type_validate( low_order_bit and DICT_N_COLS_COMPACT flags. */ if (!atomic_blobs || !page_compression) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, page_compression %lu page_compression_level %lu\n" - "InnoDB: Error: atomic_blobs %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", page_compression " ULINTPF " page_compression_level " ULINTPF "\n" + "InnoDB: Error: atomic_blobs " ULINTPF "\n", type, page_compression, page_compression_level, atomic_blobs); return(ULINT_UNDEFINED); } @@ -768,7 +785,7 @@ dict_sys_tables_type_validate( /* Validate that the atomic writes number is within allowed range. */ if (atomic_writes > ATOMIC_WRITES_OFF) { - fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, atomic_writes %lu\n", + fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", atomic_writes " ULINTPF "\n", type, atomic_writes); return(ULINT_UNDEFINED); } diff --git a/storage/xtradb/include/fil0crypt.h b/storage/xtradb/include/fil0crypt.h index cfc2d850883..e7e9676aa3a 100644 --- a/storage/xtradb/include/fil0crypt.h +++ b/storage/xtradb/include/fil0crypt.h @@ -109,7 +109,7 @@ struct fil_space_crypt_t : st_encryption_scheme The object is expected to be placed in a buffer that has been zero-initialized. */ fil_space_crypt_t( - ulint new_type, + uint new_type, uint new_min_key_version, uint new_key_id, fil_encryption_t new_encryption) @@ -117,10 +117,10 @@ struct fil_space_crypt_t : st_encryption_scheme min_key_version(new_min_key_version), page0_offset(0), encryption(new_encryption), - key_found(), + mutex(), + key_found(new_min_key_version), rotate_state() { - key_found = new_min_key_version; key_id = new_key_id; my_random_bytes(iv, sizeof(iv)); mutex_create(fil_crypt_data_mutex_key, diff --git a/storage/xtradb/include/fil0fil.ic b/storage/xtradb/include/fil0fil.ic index 1179eea8b8e..b79167baead 100644 --- a/storage/xtradb/include/fil0fil.ic +++ b/storage/xtradb/include/fil0fil.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2015, MariaDB Corporation. +Copyright (c) 2015, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -137,7 +137,7 @@ fil_page_type_validate( page_type == FIL_PAGE_TYPE_ZBLOB2 || page_type == FIL_PAGE_TYPE_COMPRESSED))) { - uint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); + ulint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED); bool page_compressed_encrypted = (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); ulint space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); @@ -148,30 +148,18 @@ fil_page_type_validate( fil_space_t* rspace = fil_space_get_by_id(space); fil_system_exit(); - /* Dump out the page info */ - fprintf(stderr, "InnoDB: Space %lu offset %lu name %s page_type %lu page_type_name %s\n" - "InnoDB: key_version %u page_compressed %d page_compressed_encrypted %d lsn %llu compressed_len %lu\n", - space, offset, rspace->name, page_type, fil_get_page_type_name(page_type), - key_version, page_compressed, page_compressed_encrypted, (ulonglong)lsn, compressed_len); - fflush(stderr); - - ut_ad(page_type == FIL_PAGE_PAGE_COMPRESSED || - page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED || - page_type == FIL_PAGE_INDEX || - page_type == FIL_PAGE_UNDO_LOG || - page_type == FIL_PAGE_INODE || - page_type == FIL_PAGE_IBUF_FREE_LIST || - page_type == FIL_PAGE_TYPE_ALLOCATED || - page_type == FIL_PAGE_IBUF_BITMAP || - page_type == FIL_PAGE_TYPE_SYS || - page_type == FIL_PAGE_TYPE_TRX_SYS || - page_type == FIL_PAGE_TYPE_FSP_HDR || - page_type == FIL_PAGE_TYPE_XDES || - page_type == FIL_PAGE_TYPE_BLOB || - page_type == FIL_PAGE_TYPE_ZBLOB || - page_type == FIL_PAGE_TYPE_ZBLOB2 || - page_type == FIL_PAGE_TYPE_COMPRESSED); + fprintf(stderr, "InnoDB: Page " ULINTPF ":" ULINTPF + " name %s page_type " ULINTPF " page_type_name %s\n" + "InnoDB: key_version " ULINTPF + " page_compressed %d page_compressed_encrypted %d lsn " + LSN_PF " compressed_len " ULINTPF "\n", + space, offset, rspace->name, page_type, + fil_get_page_type_name(page_type), + key_version, + page_compressed, page_compressed_encrypted, + lsn, compressed_len); + ut_error; return false; } From 555e52f3bc8d67d0cfe176d25e2fe0c73fdb2fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Apr 2017 11:52:25 +0300 Subject: [PATCH 48/52] MDEV-12467 encryption.create_or_replace hangs during DROP TABLE fil_crypt_thread(): Do invoke fil_crypt_complete_rotate_space() when the tablespace is about to be dropped. Also, remove a redundant check whether rotate_thread_t::space is NULL. It can only become NULL when fil_crypt_find_space_to_rotate() returns false, and in that case we would already have terminated the loop. fil_crypt_find_page_to_rotate(): Remove a redundant check for space->crypt_data == NULL. Once encryption metadata has been created for a tablespace, it cannot be removed without dropping the entire tablespace. --- storage/innobase/fil/fil0crypt.cc | 40 ++++++++++++++----------------- storage/xtradb/fil/fil0crypt.cc | 40 ++++++++++++++----------------- 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index b8892b4ec31..da8e538022d 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1742,33 +1742,27 @@ fil_crypt_find_page_to_rotate( fil_space_crypt_t *crypt_data = space->crypt_data; - /* Space might already be dropped */ - if (crypt_data) { - mutex_enter(&crypt_data->mutex); - ut_ad(key_state->key_id == crypt_data->key_id); + mutex_enter(&crypt_data->mutex); + ut_ad(key_state->key_id == crypt_data->key_id); - if (crypt_data->rotate_state.next_offset < - crypt_data->rotate_state.max_offset) { + bool found = crypt_data->rotate_state.max_offset >= + crypt_data->rotate_state.next_offset; - state->offset = crypt_data->rotate_state.next_offset; - ulint remaining = crypt_data->rotate_state.max_offset - - crypt_data->rotate_state.next_offset; + if (found) { + state->offset = crypt_data->rotate_state.next_offset; + ulint remaining = crypt_data->rotate_state.max_offset - + crypt_data->rotate_state.next_offset; - if (batch <= remaining) { - state->batch = batch; - } else { - state->batch = remaining; - } - - crypt_data->rotate_state.next_offset += batch; - mutex_exit(&crypt_data->mutex); - return true; + if (batch <= remaining) { + state->batch = batch; + } else { + state->batch = remaining; } - - mutex_exit(&crypt_data->mutex); } - return false; + crypt_data->rotate_state.next_offset += batch; + mutex_exit(&crypt_data->mutex); + return found; } /*********************************************************************** @@ -2346,7 +2340,7 @@ DECLARE_THREAD(fil_crypt_thread)( fil_crypt_start_rotate_space(&new_state, &thr); /* iterate all pages (cooperativly with other threads) */ - while (!thr.should_shutdown() && thr.space && + while (!thr.should_shutdown() && fil_crypt_find_page_to_rotate(&new_state, &thr)) { /* rotate a (set) of pages */ @@ -2355,6 +2349,8 @@ DECLARE_THREAD(fil_crypt_thread)( /* If space is marked as stopping, release space and stop rotation. */ if (thr.space->is_stopping()) { + fil_crypt_complete_rotate_space( + &new_state, &thr); fil_space_release(thr.space); thr.space = NULL; break; diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index b8892b4ec31..da8e538022d 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -1742,33 +1742,27 @@ fil_crypt_find_page_to_rotate( fil_space_crypt_t *crypt_data = space->crypt_data; - /* Space might already be dropped */ - if (crypt_data) { - mutex_enter(&crypt_data->mutex); - ut_ad(key_state->key_id == crypt_data->key_id); + mutex_enter(&crypt_data->mutex); + ut_ad(key_state->key_id == crypt_data->key_id); - if (crypt_data->rotate_state.next_offset < - crypt_data->rotate_state.max_offset) { + bool found = crypt_data->rotate_state.max_offset >= + crypt_data->rotate_state.next_offset; - state->offset = crypt_data->rotate_state.next_offset; - ulint remaining = crypt_data->rotate_state.max_offset - - crypt_data->rotate_state.next_offset; + if (found) { + state->offset = crypt_data->rotate_state.next_offset; + ulint remaining = crypt_data->rotate_state.max_offset - + crypt_data->rotate_state.next_offset; - if (batch <= remaining) { - state->batch = batch; - } else { - state->batch = remaining; - } - - crypt_data->rotate_state.next_offset += batch; - mutex_exit(&crypt_data->mutex); - return true; + if (batch <= remaining) { + state->batch = batch; + } else { + state->batch = remaining; } - - mutex_exit(&crypt_data->mutex); } - return false; + crypt_data->rotate_state.next_offset += batch; + mutex_exit(&crypt_data->mutex); + return found; } /*********************************************************************** @@ -2346,7 +2340,7 @@ DECLARE_THREAD(fil_crypt_thread)( fil_crypt_start_rotate_space(&new_state, &thr); /* iterate all pages (cooperativly with other threads) */ - while (!thr.should_shutdown() && thr.space && + while (!thr.should_shutdown() && fil_crypt_find_page_to_rotate(&new_state, &thr)) { /* rotate a (set) of pages */ @@ -2355,6 +2349,8 @@ DECLARE_THREAD(fil_crypt_thread)( /* If space is marked as stopping, release space and stop rotation. */ if (thr.space->is_stopping()) { + fil_crypt_complete_rotate_space( + &new_state, &thr); fil_space_release(thr.space); thr.space = NULL; break; From 996c7d5cb5e369de178da3482f3dfc36d57fd6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Apr 2017 17:32:02 +0300 Subject: [PATCH 49/52] MDEV-12545 Reduce the amount of fil_space_t lookups buf_flush_write_block_low(): Acquire the tablespace reference once, and pass it to lower-level functions. This is only a start; further calls may be removed later. --- storage/innobase/buf/buf0buf.cc | 96 ++++++++----------- storage/innobase/buf/buf0dblwr.cc | 4 +- storage/innobase/buf/buf0flu.cc | 16 ++-- storage/innobase/fil/fil0fil.cc | 76 +++++++++------ storage/innobase/fil/fil0pagecompress.cc | 63 ++++++------- storage/innobase/include/buf0buf.h | 18 ++-- storage/innobase/include/fil0fil.h | 29 +++--- storage/innobase/include/fil0pagecompress.h | 30 +----- storage/innobase/include/fsp0pagecompress.ic | 63 ------------- storage/xtradb/buf/buf0buf.cc | 97 ++++++++------------ storage/xtradb/buf/buf0dblwr.cc | 4 +- storage/xtradb/buf/buf0flu.cc | 16 ++-- storage/xtradb/fil/fil0fil.cc | 76 +++++++++------ storage/xtradb/fil/fil0pagecompress.cc | 62 ++++++------- storage/xtradb/include/buf0buf.h | 18 ++-- storage/xtradb/include/fil0fil.h | 27 +++--- storage/xtradb/include/fil0pagecompress.h | 30 +----- storage/xtradb/include/fsp0pagecompress.ic | 63 ------------- 18 files changed, 307 insertions(+), 481 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 2133457fcbb..bb567119a13 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -6080,71 +6080,54 @@ buf_pool_reserve_tmp_slot( return (free_slot); } -/********************************************************************//** -Encrypts a buffer page right before it's flushed to disk -@param[in,out] bpage Page control block -@param[in,out] src_frame Source page -@param[in] space_id Tablespace id -@return either unencrypted source page or decrypted page. -*/ +/** Encryption and page_compression hook that is called just before +a page is written to disk. +@param[in,out] space tablespace +@param[in,out] bpage buffer page +@param[in] src_frame physical page frame that is being encrypted +@return page frame to be written to file +(may be src_frame or an encrypted/compressed copy of it) */ UNIV_INTERN byte* buf_page_encrypt_before_write( + fil_space_t* space, buf_page_t* bpage, - byte* src_frame, - ulint space_id) + byte* src_frame) { + ut_ad(space->id == bpage->space); bpage->real_size = UNIV_PAGE_SIZE; fil_page_type_validate(src_frame); - if (bpage->offset == 0) { + switch (bpage->offset) { + case 0: /* Page 0 of a tablespace is not encrypted/compressed */ ut_ad(bpage->key_version == 0); return src_frame; - } - - if (bpage->space == TRX_SYS_SPACE && bpage->offset == TRX_SYS_PAGE_NO) { - /* don't encrypt/compress page as it contains address to dblwr buffer */ - bpage->key_version = 0; - return src_frame; - } - - fil_space_t* space = fil_space_acquire_silent(space_id); - - /* Tablespace must exist during write operation */ - if (!space) { - /* This could be true on discard if we have injected a error - case e.g. in innodb.innodb-wl5522-debug-zip so that space - is already marked as stop_new_ops = true. */ - return src_frame; + case TRX_SYS_PAGE_NO: + if (bpage->space == TRX_SYS_SPACE) { + /* don't encrypt/compress page as it contains + address to dblwr buffer */ + bpage->key_version = 0; + return src_frame; + } } fil_space_crypt_t* crypt_data = space->crypt_data; - bool encrypted = true; + const bool encrypted = crypt_data + && !crypt_data->not_encrypted() + && crypt_data->type != CRYPT_SCHEME_UNENCRYPTED + && (!crypt_data->is_default_encryption() + || srv_encrypt_tables); - if (space->crypt_data != NULL && space->crypt_data->not_encrypted()) { - /* Encryption is disabled */ - encrypted = false; - } - - if (!srv_encrypt_tables && (crypt_data == NULL || crypt_data->is_default_encryption())) { - /* Encryption is disabled */ - encrypted = false; - } - - /* Is encryption needed? */ - if (crypt_data == NULL || crypt_data->type == CRYPT_SCHEME_UNENCRYPTED) { - /* An unencrypted table */ + if (!encrypted) { bpage->key_version = 0; - encrypted = false; } - bool page_compressed = fil_space_is_page_compressed(bpage->space); + bool page_compressed = FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags); if (!encrypted && !page_compressed) { /* No need to encrypt or page compress the page */ - fil_space_release(space); return src_frame; } @@ -6172,25 +6155,21 @@ buf_page_encrypt_before_write( bpage->real_size = page_size; slot->out_buf = dst_frame = tmp; -#ifdef UNIV_DEBUG - fil_page_type_validate(tmp); -#endif - + ut_d(fil_page_type_validate(tmp)); } else { /* First we compress the page content */ ulint out_len = 0; - ulint block_size = fil_space_get_block_size(bpage->space, bpage->offset, page_size); - byte *tmp = fil_compress_page(bpage->space, - (byte *)src_frame, - slot->comp_buf, - page_size, - fil_space_get_page_compression_level(bpage->space), - block_size, - encrypted, - &out_len, - IF_LZO(slot->lzo_mem, NULL) - ); + byte *tmp = fil_compress_page( + space, + (byte *)src_frame, + slot->comp_buf, + page_size, + fsp_flags_get_page_compression_level(space->flags), + fil_space_get_block_size(space, bpage->offset), + encrypted, + &out_len, + IF_LZO(slot->lzo_mem, NULL)); bpage->real_size = out_len; @@ -6215,7 +6194,6 @@ buf_page_encrypt_before_write( fil_page_type_validate(dst_frame); #endif - fil_space_release(space); // return dst_frame which will be written return dst_frame; } diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index f99679f6fec..cedbff96a67 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -986,7 +986,7 @@ flush: srv_stats.dblwr_writes.inc(); /* Now flush the doublewrite buffer data to disk */ - fil_flush(TRX_SYS_SPACE); + fil_flush(ulint(TRX_SYS_SPACE)); /* We know that the writes have been flushed to disk now and in recovery we will find them in the doublewrite buffer @@ -1231,7 +1231,7 @@ retry: } /* Now flush the doublewrite buffer data to disk */ - fil_flush(TRX_SYS_SPACE); + fil_flush(ulint(TRX_SYS_SPACE)); /* We know that the write has been flushed to disk now and during recovery we will find it in the doublewrite buffer diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 3f03ee8256f..87a5386ce25 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -831,11 +831,12 @@ buf_flush_write_block_low( buf_flush_t flush_type, /*!< in: type of flush */ bool sync) /*!< in: true if sync IO request */ { + fil_space_t* space = fil_space_acquire(bpage->space, true); + if (!space) { + return; + } ulint zip_size = buf_page_get_zip_size(bpage); page_t* frame = NULL; - ulint space_id = buf_page_get_space(bpage); - atomic_writes_t awrites = fil_space_get_atomic_writes(space_id); - #ifdef UNIV_DEBUG buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); ut_ad(!buf_pool_mutex_own(buf_pool)); @@ -906,7 +907,7 @@ buf_flush_write_block_low( break; } - frame = buf_page_encrypt_before_write(bpage, frame, space_id); + frame = buf_page_encrypt_before_write(space, bpage, frame); if (!srv_use_doublewrite_buf || !buf_dblwr) { fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, @@ -928,7 +929,8 @@ buf_flush_write_block_low( atomic writes should be used, no doublewrite buffer is used. */ - if (awrites == ATOMIC_WRITES_ON) { + if (fsp_flags_get_atomic_writes(space->flags) + == ATOMIC_WRITES_ON) { fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, FALSE, buf_page_get_space(bpage), @@ -952,13 +954,15 @@ buf_flush_write_block_low( are working on. */ if (sync) { ut_ad(flush_type == BUF_FLUSH_SINGLE_PAGE); - fil_flush(buf_page_get_space(bpage)); + fil_flush(space); /* true means we want to evict this page from the LRU list as well. */ buf_page_io_complete(bpage, true); } + fil_space_release(space); + /* Increment the counter of I/O operations used for selecting LRU policy. */ buf_LRU_stat_inc_io(); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index ceda86e16b6..2a812fa8a9f 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -5956,31 +5956,34 @@ fil_space_get_node( return (node); } -/********************************************************************//** -Return block size of node in file space -@return file block size */ + +/** Determine the block size of the data file. +@param[in] space tablespace +@param[in] offset page number +@return block size */ UNIV_INTERN ulint -fil_space_get_block_size( -/*=====================*/ - ulint space_id, - ulint block_offset, - ulint len) +fil_space_get_block_size(const fil_space_t* space, unsigned offset) { + ut_ad(space->n_pending_ops > 0); + ulint block_size = 512; - ut_ad(!mutex_own(&fil_system->mutex)); - mutex_enter(&fil_system->mutex); - fil_space_t* space = fil_space_get_space(space_id); - - if (space) { - fil_node_t* node = fil_space_get_node(space, space_id, &block_offset, 0, len); - - if (node) { - block_size = node->file_block_size; + for (fil_node_t* node = UT_LIST_GET_FIRST(space->chain); + node != NULL; + node = UT_LIST_GET_NEXT(chain, node)) { + block_size = node->file_block_size; + if (node->size > offset) { + break; } + offset -= node->size; + } + + /* Currently supporting block size up to 4K, + fall back to default if bigger requested. */ + if (block_size > 4096) { + block_size = 512; } - mutex_exit(&fil_system->mutex); return block_size; } @@ -6334,14 +6337,29 @@ fil_flush( mutex_exit(&fil_system->mutex); } -/**********************************************************************//** -Flushes to disk the writes in file spaces of the given type possibly cached by -the OS. */ +/** Flush a tablespace. +@param[in,out] space tablespace to flush */ UNIV_INTERN void -fil_flush_file_spaces( -/*==================*/ - ulint purpose) /*!< in: FIL_TABLESPACE, FIL_LOG */ +fil_flush(fil_space_t* space) +{ + ut_ad(space->n_pending_ops > 0); + + if (!space->is_stopping()) { + mutex_enter(&fil_system->mutex); + if (!space->is_stopping()) { + fil_flush_low(space); + } + mutex_exit(&fil_system->mutex); + } +} + +/** Flush to disk the writes in file spaces of the given type +possibly cached by the OS. +@param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG */ +UNIV_INTERN +void +fil_flush_file_spaces(ulint purpose) { fil_space_t* space; ulint* space_ids; @@ -6769,12 +6787,14 @@ fil_iterate( if (page_compressed) { ulint len = 0; - fil_compress_page(space_id, + + fil_compress_page( + NULL, src, NULL, size, - fil_space_get_page_compression_level(space_id), - fil_space_get_block_size(space_id, offset, size), + 0,/* FIXME: compression level */ + 512,/* FIXME: use proper block size */ encrypted, &len, NULL); @@ -6785,6 +6805,8 @@ fil_iterate( /* If tablespace is encrypted, encrypt page before we write it back. Note that we should not encrypt the buffer that is in buffer pool. */ + /* NOTE: At this stage of IMPORT the + buffer pool is not being used at all! */ if (decrypted && encrypted) { byte *dest = writeptr + (i * size); ulint space = mach_read_from_4( diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index 42f894f08d7..73df69beb90 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2016, MariaDB Corporation. All Rights Reserved. +Copyright (C) 2013, 2017, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -91,8 +91,7 @@ UNIV_INTERN byte* fil_compress_page( /*==============*/ - ulint space_id, /*!< in: tablespace id of the - table. */ + fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */ byte* buf, /*!< in: buffer from which to write; in aio this must be appropriately aligned */ byte* out_buf, /*!< out: compressed buffer */ @@ -110,9 +109,12 @@ fil_compress_page( ulint write_size=0; /* Cache to avoid change during function execution */ ulint comp_method = innodb_compression_algorithm; - ulint orig_page_type; bool allocated=false; + /* page_compression does not apply to tables or tablespaces + that use ROW_FORMAT=COMPRESSED */ + ut_ad(!space || !FSP_FLAGS_GET_ZIP_SSIZE(space->flags)); + if (encrypted) { header_len += FIL_PAGE_COMPRESSION_METHOD_SIZE; } @@ -133,21 +135,14 @@ fil_compress_page( ut_ad(len); ut_ad(out_len); - /* read original page type */ - orig_page_type = mach_read_from_2(buf + FIL_PAGE_TYPE); - - fil_system_enter(); - fil_space_t* space = fil_space_get_by_id(space_id); - fil_system_exit(); - /* Let's not compress file space header or extent descriptor */ - if (orig_page_type == 0 || - orig_page_type == FIL_PAGE_TYPE_FSP_HDR || - orig_page_type == FIL_PAGE_TYPE_XDES || - orig_page_type == FIL_PAGE_PAGE_COMPRESSED) { + switch (fil_page_get_type(buf)) { + case 0: + case FIL_PAGE_TYPE_FSP_HDR: + case FIL_PAGE_TYPE_XDES: + case FIL_PAGE_PAGE_COMPRESSED: *out_len = len; - goto err_exit; } @@ -157,11 +152,11 @@ fil_compress_page( comp_level = page_zip_level; } -#ifdef UNIV_PAGECOMPRESS_DEBUG - ib_logf(IB_LOG_LEVEL_INFO, - "Preparing for compress for space %lu name %s len %lu.", - space_id, fil_space_name(space), len); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ + DBUG_PRINT("compress", + ("Preparing for space " ULINTPF " '%s' len " ULINTPF, + space ? space->id : 0, + space ? space->name : "(import)", + len)); write_size = UNIV_PAGE_SIZE - header_len; @@ -306,10 +301,13 @@ fil_compress_page( if (err != Z_OK) { /* If error we leave the actual page as it was */ - if (space->printed_compression_failure == false) { + if (space && !space->printed_compression_failure) { ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu rt %d write %lu.", - space_id, fil_space_name(space), len, err, write_size); + "Compression failed for space " + ULINTPF " name %s len " ULINTPF + " rt %d write " ULINTPF ".", + space->id, space->name, len, err, + write_size); space->printed_compression_failure = true; } @@ -367,9 +365,8 @@ fil_compress_page( fil_decompress_page(uncomp_page, comp_page, ulong(len), NULL); - if(buf_page_is_corrupted(false, uncomp_page, 0, space)) { - buf_page_print(uncomp_page, 0, BUF_PAGE_PRINT_NO_CRASH); - ut_error; + if (buf_page_is_corrupted(false, uncomp_page, 0, space)) { + buf_page_print(uncomp_page, 0, 0); } ut_free(comp_page); @@ -388,7 +385,6 @@ fil_compress_page( /* Actual write needs to be alligned on block size */ if (write_size % block_size) { size_t tmp = write_size; - write_size = (size_t)ut_uint64_align_up((ib_uint64_t)write_size, block_size); /* Clean up the end of buffer */ memset(out_buf+tmp, 0, write_size - tmp); @@ -398,11 +394,12 @@ fil_compress_page( #endif } -#ifdef UNIV_PAGECOMPRESS_DEBUG - ib_logf(IB_LOG_LEVEL_INFO, - "Compression succeeded for space %lu name %s len %lu out_len %lu.", - space_id, fil_space_name(space), len, write_size); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ + DBUG_PRINT("compress", + ("Succeeded for space " ULINTPF + " '%s' len " ULINTPF " out_len " ULINTPF, + space ? space->id : 0, + space ? space->name : "(import)", + len, write_size)); srv_stats.page_compression_saved.add((len - write_size)); srv_stats.pages_page_compressed.inc(); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 643e8c731e5..b4d39351370 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1502,17 +1502,19 @@ buf_flush_update_zip_checksum( #endif /* !UNIV_HOTBACKUP */ -/********************************************************************//** -The hook that is called just before a page is written to disk. -The function encrypts the content of the page and returns a pointer -to a frame that will be written instead of the real frame. */ +/** Encryption and page_compression hook that is called just before +a page is written to disk. +@param[in,out] space tablespace +@param[in,out] bpage buffer page +@param[in] src_frame physical page frame that is being encrypted +@return page frame to be written to file +(may be src_frame or an encrypted/compressed copy of it) */ UNIV_INTERN byte* buf_page_encrypt_before_write( -/*==========================*/ - buf_page_t* page, /*!< in/out: buffer page to be flushed */ - byte* frame, /*!< in: src frame */ - ulint space_id); /*!< in: space id */ + fil_space_t* space, + buf_page_t* bpage, + byte* src_frame); /********************************************************************** The hook that is called after page is written to disk. diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 3d7ae49f8ae..ba9e5029c6d 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1135,14 +1135,18 @@ fil_flush( /*======*/ ulint space_id); /*!< in: file space id (this can be a group of log files or a tablespace of the database) */ -/**********************************************************************//** -Flushes to disk writes in file spaces of the given type possibly cached by -the OS. */ +/** Flush a tablespace. +@param[in,out] space tablespace to flush */ UNIV_INTERN void -fil_flush_file_spaces( -/*==================*/ - ulint purpose); /*!< in: FIL_TABLESPACE, FIL_LOG */ +fil_flush(fil_space_t* space); + +/** Flush to disk the writes in file spaces of the given type +possibly cached by the OS. +@param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG */ +UNIV_INTERN +void +fil_flush_file_spaces(ulint purpose); /******************************************************************//** Checks the consistency of the tablespace cache. @return TRUE if ok */ @@ -1430,18 +1434,13 @@ fil_get_next_space_safe( /*====================*/ ulint id); /*!< in: previous space id */ - -/*******************************************************************//** -Returns the block size of the file space +/** Determine the block size of the data file. +@param[in] space tablespace +@param[in] offset page number @return block size */ UNIV_INTERN ulint -fil_space_get_block_size( -/*=====================*/ - ulint id, /*!< in: space id */ - ulint offset, /*!< in: page offset */ - ulint len); /*!< in: page len */ - +fil_space_get_block_size(const fil_space_t* space, unsigned offset); #endif /* UNIV_INNOCHECKSUM */ #ifndef UNIV_INNOCHECKSUM diff --git a/storage/innobase/include/fil0pagecompress.h b/storage/innobase/include/fil0pagecompress.h index 1fe5cb66bf6..73667c5420e 100644 --- a/storage/innobase/include/fil0pagecompress.h +++ b/storage/innobase/include/fil0pagecompress.h @@ -30,33 +30,6 @@ atomic writes information to table space. Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com ***********************************************************************/ -/*******************************************************************//** -Returns the page compression level flag of the space, or 0 if the space -is not compressed. The tablespace must be cached in the memory cache. -@return page compression level if page compressed, ULINT_UNDEFINED if space not found */ -UNIV_INLINE -ulint -fil_space_get_page_compression_level( -/*=================================*/ - ulint id); /*!< in: space id */ -/*******************************************************************//** -Returns the page compression flag of the space, or false if the space -is not compressed. The tablespace must be cached in the memory cache. -@return true if page compressed, false if not or space not found */ -UNIV_INLINE -bool -fil_space_is_page_compressed( -/*=========================*/ - ulint id); /*!< in: space id */ -/*******************************************************************//** -Returns the atomic writes flag of the space, or false if the space -is not using atomic writes. The tablespace must be cached in the memory cache. -@return atomic write table option value */ -UNIV_INLINE -atomic_writes_t -fil_space_get_atomic_writes( -/*=========================*/ - ulint id); /*!< in: space id */ /*******************************************************************//** Find out wheather the page is index page or not @return true if page type index page, false if not */ @@ -84,8 +57,7 @@ UNIV_INTERN byte* fil_compress_page( /*==============*/ - ulint space_id, /*!< in: tablespace id of the - table. */ + fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */ byte* buf, /*!< in: buffer from which to write; in aio this must be appropriately aligned */ byte* out_buf, /*!< out: compressed buffer */ diff --git a/storage/innobase/include/fsp0pagecompress.ic b/storage/innobase/include/fsp0pagecompress.ic index 48163277feb..14f968e319e 100644 --- a/storage/innobase/include/fsp0pagecompress.ic +++ b/storage/innobase/include/fsp0pagecompress.ic @@ -85,47 +85,6 @@ fil_page_is_compressed_encrypted( return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); } -#ifndef UNIV_INNOCHECKSUM -/*******************************************************************//** -Returns the page compression level of the space, or 0 if the space -is not compressed. The tablespace must be cached in the memory cache. -@return page compression level, 0 if space not found */ -UNIV_INLINE -ulint -fil_space_get_page_compression_level( -/*=================================*/ - ulint id) /*!< in: space id */ -{ - ulint flags; - - flags = fil_space_get_flags(id); - - if (flags && flags != ULINT_UNDEFINED) { - - return(fsp_flags_get_page_compression_level(flags)); - } - - return(0); -} - -/*******************************************************************//** -Extract the page compression from space. -@return true if space is page compressed, false if space is not found -or space is not page compressed. */ -UNIV_INLINE -bool -fil_space_is_page_compressed( -/*=========================*/ - ulint id) /*!< in: space id */ -{ - ulint flags = fil_space_get_flags(id); - - return(flags != ULINT_UNDEFINED - && FSP_FLAGS_HAS_PAGE_COMPRESSION(flags)); -} - -#endif /* UNIV_INNOCHECKSUM */ - /****************************************************************//** Get the name of the compression algorithm used for page compression. @@ -165,28 +124,6 @@ fil_get_compression_alg_name( } #ifndef UNIV_INNOCHECKSUM -/*******************************************************************//** -Returns the atomic writes flag of the space, or false if the space -is not using atomic writes. The tablespace must be cached in the memory cache. -@return atomic writes table option value */ -UNIV_INLINE -atomic_writes_t -fil_space_get_atomic_writes( -/*========================*/ - ulint id) /*!< in: space id */ -{ - ulint flags; - - flags = fil_space_get_flags(id); - - if (flags && flags != ULINT_UNDEFINED) { - - return((atomic_writes_t)fsp_flags_get_atomic_writes(flags)); - } - - return((atomic_writes_t)0); -} - /*******************************************************************//** Find out wheather the page is page compressed with lzo method @return true if page is page compressed with lzo method, false if not */ diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 7f77f96c2fe..394d2be6838 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -6241,70 +6241,54 @@ buf_pool_reserve_tmp_slot( return (free_slot); } -/********************************************************************//** -Encrypts a buffer page right before it's flushed to disk -@param[in,out] bpage Page control block -@param[in,out] src_frame Source page -@param[in] space_id Tablespace id -@return either unencrypted source page or decrypted page. -*/ +/** Encryption and page_compression hook that is called just before +a page is written to disk. +@param[in,out] space tablespace +@param[in,out] bpage buffer page +@param[in] src_frame physical page frame that is being encrypted +@return page frame to be written to file +(may be src_frame or an encrypted/compressed copy of it) */ +UNIV_INTERN byte* buf_page_encrypt_before_write( + fil_space_t* space, buf_page_t* bpage, - byte* src_frame, - ulint space_id) + byte* src_frame) { + ut_ad(space->id == bpage->space); bpage->real_size = UNIV_PAGE_SIZE; fil_page_type_validate(src_frame); - if (bpage->offset == 0) { + switch (bpage->offset) { + case 0: /* Page 0 of a tablespace is not encrypted/compressed */ ut_ad(bpage->key_version == 0); return src_frame; - } - - if (bpage->space == TRX_SYS_SPACE && bpage->offset == TRX_SYS_PAGE_NO) { - /* don't encrypt/compress page as it contains address to dblwr buffer */ - bpage->key_version = 0; - return src_frame; - } - - fil_space_t* space = fil_space_acquire_silent(space_id); - - /* Tablespace must exist during write operation */ - if (!space) { - /* This could be true on discard if we have injected a error - case e.g. in innodb.innodb-wl5522-debug-zip so that space - is already marked as stop_new_ops = true. */ - return src_frame; + case TRX_SYS_PAGE_NO: + if (bpage->space == TRX_SYS_SPACE) { + /* don't encrypt/compress page as it contains + address to dblwr buffer */ + bpage->key_version = 0; + return src_frame; + } } fil_space_crypt_t* crypt_data = space->crypt_data; - bool encrypted = true; + const bool encrypted = crypt_data + && !crypt_data->not_encrypted() + && crypt_data->type != CRYPT_SCHEME_UNENCRYPTED + && (!crypt_data->is_default_encryption() + || srv_encrypt_tables); - if (space->crypt_data != NULL && space->crypt_data->not_encrypted()) { - /* Encryption is disabled */ - encrypted = false; - } - - if (!srv_encrypt_tables && (crypt_data == NULL || crypt_data->is_default_encryption())) { - /* Encryption is disabled */ - encrypted = false; - } - - /* Is encryption needed? */ - if (crypt_data == NULL || crypt_data->type == CRYPT_SCHEME_UNENCRYPTED) { - /* An unencrypted table */ + if (!encrypted) { bpage->key_version = 0; - encrypted = false; } - bool page_compressed = fil_space_is_page_compressed(bpage->space); + bool page_compressed = FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags); if (!encrypted && !page_compressed) { /* No need to encrypt or page compress the page */ - fil_space_release(space); return src_frame; } @@ -6332,25 +6316,21 @@ buf_page_encrypt_before_write( bpage->real_size = page_size; slot->out_buf = dst_frame = tmp; -#ifdef UNIV_DEBUG - fil_page_type_validate(tmp); -#endif - + ut_d(fil_page_type_validate(tmp)); } else { /* First we compress the page content */ ulint out_len = 0; - ulint block_size = fil_space_get_block_size(bpage->space, bpage->offset, page_size); - byte *tmp = fil_compress_page(bpage->space, - (byte *)src_frame, - slot->comp_buf, - page_size, - fil_space_get_page_compression_level(bpage->space), - block_size, - encrypted, - &out_len, - IF_LZO(slot->lzo_mem, NULL) - ); + byte *tmp = fil_compress_page( + space, + (byte *)src_frame, + slot->comp_buf, + page_size, + fsp_flags_get_page_compression_level(space->flags), + fil_space_get_block_size(space, bpage->offset), + encrypted, + &out_len, + IF_LZO(slot->lzo_mem, NULL)); bpage->real_size = out_len; @@ -6375,7 +6355,6 @@ buf_page_encrypt_before_write( fil_page_type_validate(dst_frame); #endif - fil_space_release(space); // return dst_frame which will be written return dst_frame; } diff --git a/storage/xtradb/buf/buf0dblwr.cc b/storage/xtradb/buf/buf0dblwr.cc index ddef13ef8ea..55c5e4d543a 100644 --- a/storage/xtradb/buf/buf0dblwr.cc +++ b/storage/xtradb/buf/buf0dblwr.cc @@ -1001,7 +1001,7 @@ flush: srv_stats.dblwr_writes.inc(); /* Now flush the doublewrite buffer data to disk */ - fil_flush(TRX_SYS_SPACE); + fil_flush(ulint(TRX_SYS_SPACE)); /* We know that the writes have been flushed to disk now and in recovery we will find them in the doublewrite buffer @@ -1249,7 +1249,7 @@ retry: } /* Now flush the doublewrite buffer data to disk */ - fil_flush(TRX_SYS_SPACE); + fil_flush(ulint(TRX_SYS_SPACE)); /* We know that the write has been flushed to disk now and during recovery we will find it in the doublewrite buffer diff --git a/storage/xtradb/buf/buf0flu.cc b/storage/xtradb/buf/buf0flu.cc index 4804d71a51f..f71bdb9f69a 100644 --- a/storage/xtradb/buf/buf0flu.cc +++ b/storage/xtradb/buf/buf0flu.cc @@ -873,11 +873,12 @@ buf_flush_write_block_low( buf_flush_t flush_type, /*!< in: type of flush */ bool sync) /*!< in: true if sync IO request */ { + fil_space_t* space = fil_space_acquire(bpage->space, true); + if (!space) { + return; + } ulint zip_size = buf_page_get_zip_size(bpage); page_t* frame = NULL; - ulint space_id = buf_page_get_space(bpage); - atomic_writes_t awrites = fil_space_get_atomic_writes(space_id); - #ifdef UNIV_DEBUG buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); ut_ad(!mutex_own(&buf_pool->LRU_list_mutex)); @@ -947,7 +948,7 @@ buf_flush_write_block_low( break; } - frame = buf_page_encrypt_before_write(bpage, frame, space_id); + frame = buf_page_encrypt_before_write(space, bpage, frame); if (!srv_use_doublewrite_buf || !buf_dblwr) { fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, @@ -968,7 +969,8 @@ buf_flush_write_block_low( atomic writes should be used, no doublewrite buffer is used. */ - if (awrites == ATOMIC_WRITES_ON) { + if (fsp_flags_get_atomic_writes(space->flags) + == ATOMIC_WRITES_ON) { fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, FALSE, buf_page_get_space(bpage), @@ -991,10 +993,12 @@ buf_flush_write_block_low( are working on. */ if (sync) { ut_ad(flush_type == BUF_FLUSH_SINGLE_PAGE); - fil_flush(buf_page_get_space(bpage)); + fil_flush(space); buf_page_io_complete(bpage); } + fil_space_release(space); + /* Increment the counter of I/O operations used for selecting LRU policy. */ buf_LRU_stat_inc_io(); diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index fba7d5d8e38..e504ab3947e 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -5993,31 +5993,34 @@ fil_space_get_node( return (node); } -/********************************************************************//** -Return block size of node in file space -@return file block size */ + +/** Determine the block size of the data file. +@param[in] space tablespace +@param[in] offset page number +@return block size */ UNIV_INTERN ulint -fil_space_get_block_size( -/*=====================*/ - ulint space_id, - ulint block_offset, - ulint len) +fil_space_get_block_size(const fil_space_t* space, unsigned offset) { + ut_ad(space->n_pending_ops > 0); + ulint block_size = 512; - ut_ad(!mutex_own(&fil_system->mutex)); - mutex_enter(&fil_system->mutex); - fil_space_t* space = fil_space_get_space(space_id); - - if (space) { - fil_node_t* node = fil_space_get_node(space, space_id, &block_offset, 0, len); - - if (node) { - block_size = node->file_block_size; + for (fil_node_t* node = UT_LIST_GET_FIRST(space->chain); + node != NULL; + node = UT_LIST_GET_NEXT(chain, node)) { + block_size = node->file_block_size; + if (node->size > offset) { + break; } + offset -= node->size; + } + + /* Currently supporting block size up to 4K, + fall back to default if bigger requested. */ + if (block_size > 4096) { + block_size = 512; } - mutex_exit(&fil_system->mutex); return block_size; } @@ -6398,14 +6401,29 @@ fil_flush( mutex_exit(&fil_system->mutex); } -/**********************************************************************//** -Flushes to disk the writes in file spaces of the given type possibly cached by -the OS. */ +/** Flush a tablespace. +@param[in,out] space tablespace to flush */ UNIV_INTERN void -fil_flush_file_spaces( -/*==================*/ - ulint purpose) /*!< in: FIL_TABLESPACE, FIL_LOG */ +fil_flush(fil_space_t* space) +{ + ut_ad(space->n_pending_ops > 0); + + if (!space->is_stopping()) { + mutex_enter(&fil_system->mutex); + if (!space->is_stopping()) { + fil_flush_low(space); + } + mutex_exit(&fil_system->mutex); + } +} + +/** Flush to disk the writes in file spaces of the given type +possibly cached by the OS. +@param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG */ +UNIV_INTERN +void +fil_flush_file_spaces(ulint purpose) { fil_space_t* space; ulint* space_ids; @@ -6833,12 +6851,14 @@ fil_iterate( if (page_compressed) { ulint len = 0; - fil_compress_page(space_id, + + fil_compress_page( + NULL, src, NULL, size, - fil_space_get_page_compression_level(space_id), - fil_space_get_block_size(space_id, offset, size), + 0,/* FIXME: compression level */ + 512,/* FIXME: use proper block size */ encrypted, &len, NULL); @@ -6849,6 +6869,8 @@ fil_iterate( /* If tablespace is encrypted, encrypt page before we write it back. Note that we should not encrypt the buffer that is in buffer pool. */ + /* NOTE: At this stage of IMPORT the + buffer pool is not being used at all! */ if (decrypted && encrypted) { byte *dest = writeptr + (i * size); ulint space = mach_read_from_4( diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index 655460c57ac..73df69beb90 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2016, MariaDB Corporation. All Rights Reserved. +Copyright (C) 2013, 2017, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -91,8 +91,7 @@ UNIV_INTERN byte* fil_compress_page( /*==============*/ - ulint space_id, /*!< in: tablespace id of the - table. */ + fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */ byte* buf, /*!< in: buffer from which to write; in aio this must be appropriately aligned */ byte* out_buf, /*!< out: compressed buffer */ @@ -110,9 +109,12 @@ fil_compress_page( ulint write_size=0; /* Cache to avoid change during function execution */ ulint comp_method = innodb_compression_algorithm; - ulint orig_page_type; bool allocated=false; + /* page_compression does not apply to tables or tablespaces + that use ROW_FORMAT=COMPRESSED */ + ut_ad(!space || !FSP_FLAGS_GET_ZIP_SSIZE(space->flags)); + if (encrypted) { header_len += FIL_PAGE_COMPRESSION_METHOD_SIZE; } @@ -133,21 +135,14 @@ fil_compress_page( ut_ad(len); ut_ad(out_len); - /* read original page type */ - orig_page_type = mach_read_from_2(buf + FIL_PAGE_TYPE); - - fil_system_enter(); - fil_space_t* space = fil_space_get_by_id(space_id); - fil_system_exit(); - /* Let's not compress file space header or extent descriptor */ - if (orig_page_type == 0 || - orig_page_type == FIL_PAGE_TYPE_FSP_HDR || - orig_page_type == FIL_PAGE_TYPE_XDES || - orig_page_type == FIL_PAGE_PAGE_COMPRESSED) { + switch (fil_page_get_type(buf)) { + case 0: + case FIL_PAGE_TYPE_FSP_HDR: + case FIL_PAGE_TYPE_XDES: + case FIL_PAGE_PAGE_COMPRESSED: *out_len = len; - goto err_exit; } @@ -157,11 +152,11 @@ fil_compress_page( comp_level = page_zip_level; } -#ifdef UNIV_PAGECOMPRESS_DEBUG - ib_logf(IB_LOG_LEVEL_INFO, - "Preparing for compress for space %lu name %s len %lu.", - space_id, fil_space_name(space), len); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ + DBUG_PRINT("compress", + ("Preparing for space " ULINTPF " '%s' len " ULINTPF, + space ? space->id : 0, + space ? space->name : "(import)", + len)); write_size = UNIV_PAGE_SIZE - header_len; @@ -306,10 +301,13 @@ fil_compress_page( if (err != Z_OK) { /* If error we leave the actual page as it was */ - if (space->printed_compression_failure == false) { + if (space && !space->printed_compression_failure) { ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu rt %d write %lu.", - space_id, fil_space_name(space), len, err, write_size); + "Compression failed for space " + ULINTPF " name %s len " ULINTPF + " rt %d write " ULINTPF ".", + space->id, space->name, len, err, + write_size); space->printed_compression_failure = true; } @@ -367,9 +365,8 @@ fil_compress_page( fil_decompress_page(uncomp_page, comp_page, ulong(len), NULL); - if(buf_page_is_corrupted(false, uncomp_page, 0, space)) { - buf_page_print(uncomp_page, 0, BUF_PAGE_PRINT_NO_CRASH); - ut_error; + if (buf_page_is_corrupted(false, uncomp_page, 0, space)) { + buf_page_print(uncomp_page, 0, 0); } ut_free(comp_page); @@ -397,11 +394,12 @@ fil_compress_page( #endif } -#ifdef UNIV_PAGECOMPRESS_DEBUG - ib_logf(IB_LOG_LEVEL_INFO, - "Compression succeeded for space %lu name %s len %lu out_len %lu.", - space_id, fil_space_name(space), len, write_size); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ + DBUG_PRINT("compress", + ("Succeeded for space " ULINTPF + " '%s' len " ULINTPF " out_len " ULINTPF, + space ? space->id : 0, + space ? space->name : "(import)", + len, write_size)); srv_stats.page_compression_saved.add((len - write_size)); srv_stats.pages_page_compressed.inc(); diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index 1774d9445ff..4a632e2345f 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -1534,17 +1534,19 @@ buf_own_zip_mutex_for_page( MY_ATTRIBUTE((nonnull,warn_unused_result)); #endif /* UNIV_DEBUG */ -/********************************************************************//** -The hook that is called just before a page is written to disk. -The function encrypts the content of the page and returns a pointer -to a frame that will be written instead of the real frame. */ +/** Encryption and page_compression hook that is called just before +a page is written to disk. +@param[in,out] space tablespace +@param[in,out] bpage buffer page +@param[in] src_frame physical page frame that is being encrypted +@return page frame to be written to file +(may be src_frame or an encrypted/compressed copy of it) */ UNIV_INTERN byte* buf_page_encrypt_before_write( -/*==========================*/ - buf_page_t* page, /*!< in/out: buffer page to be flushed */ - byte* frame, /*!< in: src frame */ - ulint space_id); /*!< in: space id */ + fil_space_t* space, + buf_page_t* bpage, + byte* src_frame); /********************************************************************** The hook that is called after page is written to disk. diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index 698039afede..fe7cc60d1e4 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -1120,16 +1120,13 @@ _fil_io( #define fil_io(type, sync, space_id, zip_size, block_offset, byte_offset, len, buf, message, write_size) \ _fil_io(type, sync, space_id, zip_size, block_offset, byte_offset, len, buf, message, write_size, NULL) -/*******************************************************************//** -Returns the block size of the file space +/** Determine the block size of the data file. +@param[in] space tablespace +@param[in] offset page number @return block size */ UNIV_INTERN ulint -fil_space_get_block_size( -/*=====================*/ - ulint id, /*!< in: space id */ - ulint offset, /*!< in: page offset */ - ulint len); /*!< in: page len */ +fil_space_get_block_size(const fil_space_t* space, unsigned offset); /**********************************************************************//** Waits for an aio operation to complete. This function is used to write the @@ -1151,14 +1148,18 @@ fil_flush( /*======*/ ulint space_id); /*!< in: file space id (this can be a group of log files or a tablespace of the database) */ -/**********************************************************************//** -Flushes to disk writes in file spaces of the given type possibly cached by -the OS. */ +/** Flush a tablespace. +@param[in,out] space tablespace to flush */ UNIV_INTERN void -fil_flush_file_spaces( -/*==================*/ - ulint purpose); /*!< in: FIL_TABLESPACE, FIL_LOG */ +fil_flush(fil_space_t* space); + +/** Flush to disk the writes in file spaces of the given type +possibly cached by the OS. +@param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG */ +UNIV_INTERN +void +fil_flush_file_spaces(ulint purpose); /******************************************************************//** Checks the consistency of the tablespace cache. @return TRUE if ok */ diff --git a/storage/xtradb/include/fil0pagecompress.h b/storage/xtradb/include/fil0pagecompress.h index 1fe5cb66bf6..73667c5420e 100644 --- a/storage/xtradb/include/fil0pagecompress.h +++ b/storage/xtradb/include/fil0pagecompress.h @@ -30,33 +30,6 @@ atomic writes information to table space. Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com ***********************************************************************/ -/*******************************************************************//** -Returns the page compression level flag of the space, or 0 if the space -is not compressed. The tablespace must be cached in the memory cache. -@return page compression level if page compressed, ULINT_UNDEFINED if space not found */ -UNIV_INLINE -ulint -fil_space_get_page_compression_level( -/*=================================*/ - ulint id); /*!< in: space id */ -/*******************************************************************//** -Returns the page compression flag of the space, or false if the space -is not compressed. The tablespace must be cached in the memory cache. -@return true if page compressed, false if not or space not found */ -UNIV_INLINE -bool -fil_space_is_page_compressed( -/*=========================*/ - ulint id); /*!< in: space id */ -/*******************************************************************//** -Returns the atomic writes flag of the space, or false if the space -is not using atomic writes. The tablespace must be cached in the memory cache. -@return atomic write table option value */ -UNIV_INLINE -atomic_writes_t -fil_space_get_atomic_writes( -/*=========================*/ - ulint id); /*!< in: space id */ /*******************************************************************//** Find out wheather the page is index page or not @return true if page type index page, false if not */ @@ -84,8 +57,7 @@ UNIV_INTERN byte* fil_compress_page( /*==============*/ - ulint space_id, /*!< in: tablespace id of the - table. */ + fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */ byte* buf, /*!< in: buffer from which to write; in aio this must be appropriately aligned */ byte* out_buf, /*!< out: compressed buffer */ diff --git a/storage/xtradb/include/fsp0pagecompress.ic b/storage/xtradb/include/fsp0pagecompress.ic index 48163277feb..14f968e319e 100644 --- a/storage/xtradb/include/fsp0pagecompress.ic +++ b/storage/xtradb/include/fsp0pagecompress.ic @@ -85,47 +85,6 @@ fil_page_is_compressed_encrypted( return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); } -#ifndef UNIV_INNOCHECKSUM -/*******************************************************************//** -Returns the page compression level of the space, or 0 if the space -is not compressed. The tablespace must be cached in the memory cache. -@return page compression level, 0 if space not found */ -UNIV_INLINE -ulint -fil_space_get_page_compression_level( -/*=================================*/ - ulint id) /*!< in: space id */ -{ - ulint flags; - - flags = fil_space_get_flags(id); - - if (flags && flags != ULINT_UNDEFINED) { - - return(fsp_flags_get_page_compression_level(flags)); - } - - return(0); -} - -/*******************************************************************//** -Extract the page compression from space. -@return true if space is page compressed, false if space is not found -or space is not page compressed. */ -UNIV_INLINE -bool -fil_space_is_page_compressed( -/*=========================*/ - ulint id) /*!< in: space id */ -{ - ulint flags = fil_space_get_flags(id); - - return(flags != ULINT_UNDEFINED - && FSP_FLAGS_HAS_PAGE_COMPRESSION(flags)); -} - -#endif /* UNIV_INNOCHECKSUM */ - /****************************************************************//** Get the name of the compression algorithm used for page compression. @@ -165,28 +124,6 @@ fil_get_compression_alg_name( } #ifndef UNIV_INNOCHECKSUM -/*******************************************************************//** -Returns the atomic writes flag of the space, or false if the space -is not using atomic writes. The tablespace must be cached in the memory cache. -@return atomic writes table option value */ -UNIV_INLINE -atomic_writes_t -fil_space_get_atomic_writes( -/*========================*/ - ulint id) /*!< in: space id */ -{ - ulint flags; - - flags = fil_space_get_flags(id); - - if (flags && flags != ULINT_UNDEFINED) { - - return((atomic_writes_t)fsp_flags_get_atomic_writes(flags)); - } - - return((atomic_writes_t)0); -} - /*******************************************************************//** Find out wheather the page is page compressed with lzo method @return true if page is page compressed with lzo method, false if not */ From 200ef5134483c05442b76b7fdda01297d43a6985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Apr 2017 18:29:50 +0300 Subject: [PATCH 50/52] Fix a compilation error --- storage/innobase/fil/fil0pagecompress.cc | 67 +++++++++++++++--------- storage/innobase/include/fil0fil.h | 10 +--- storage/innobase/include/fil0fil.ic | 22 -------- storage/xtradb/fil/fil0pagecompress.cc | 67 +++++++++++++++--------- storage/xtradb/include/fil0fil.h | 10 +--- storage/xtradb/include/fil0fil.ic | 22 -------- 6 files changed, 84 insertions(+), 114 deletions(-) diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index 73df69beb90..8b2449983df 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -171,12 +171,15 @@ fil_compress_page( /* If error we leave the actual page as it was */ #ifndef UNIV_PAGECOMPRESS_DEBUG - if (space->printed_compression_failure == false) { + if (space && !space->printed_compression_failure) { + space->printed_compression_failure = true; #endif ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu rt %d write %lu.", - space_id, fil_space_name(space), len, err, write_size); - space->printed_compression_failure = true; + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + err, write_size); #ifndef UNIV_PAGECOMPRESS_DEBUG } #endif @@ -192,11 +195,14 @@ fil_compress_page( buf, len, out_buf+header_len, &write_size, lzo_mem); if (err != LZO_E_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space->printed_compression_failure == false) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu err %d write_size %lu.", - space_id, fil_space_name(space), len, err, write_size); + if (space && !space->printed_compression_failure) { space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + err, write_size); } srv_stats.pages_page_compression_error.inc(); @@ -221,11 +227,14 @@ fil_compress_page( (size_t)write_size); if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { - if (space->printed_compression_failure == false) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu err %d write_size %lu", - space_id, fil_space_name(space), len, err, out_pos); + if (space && !space->printed_compression_failure) { space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + err, out_pos); } srv_stats.pages_page_compression_error.inc(); @@ -252,11 +261,14 @@ fil_compress_page( 0); if (err != BZ_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space->printed_compression_failure == false) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu err %d write_size %lu.", - space_id, fil_space_name(space), len, err, write_size); + if (space && !space->printed_compression_failure) { space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + err, write_size); } srv_stats.pages_page_compression_error.inc(); @@ -279,11 +291,14 @@ fil_compress_page( (size_t*)&write_size); if (cstatus != SNAPPY_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space->printed_compression_failure == false) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu err %d write_size %lu.", - space_id, fil_space_name(space), len, (int)cstatus, write_size); + if (space && !space->printed_compression_failure) { space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + (int)cstatus, write_size); } srv_stats.pages_page_compression_error.inc(); @@ -302,13 +317,13 @@ fil_compress_page( /* If error we leave the actual page as it was */ if (space && !space->printed_compression_failure) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " - ULINTPF " name %s len " ULINTPF - " rt %d write " ULINTPF ".", - space->id, space->name, len, err, - write_size); space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " rt %d write_size " ULINTPF ".", + space->id, space->name, len, + err, write_size); } srv_stats.pages_page_compression_error.inc(); diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index ba9e5029c6d..69594b4ad1d 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2013, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1366,14 +1366,6 @@ fil_user_tablespace_restore_page( ulint page_no); /* in: page_no to obtain from double write buffer */ -/*******************************************************************//** -Return space flags */ -UNIV_INLINE -ulint -fil_space_flags( -/*===========*/ - fil_space_t* space); /*!< in: space */ - /*******************************************************************//** Returns a pointer to the file_space_t that is in the memory cache associated with a space id. diff --git a/storage/innobase/include/fil0fil.ic b/storage/innobase/include/fil0fil.ic index b79167baead..6c2504c9f8c 100644 --- a/storage/innobase/include/fil0fil.ic +++ b/storage/innobase/include/fil0fil.ic @@ -26,28 +26,6 @@ Created 31/03/2015 Jan Lindström #ifndef fil0fil_ic #define fil0fil_ic -/*******************************************************************//** -Return space name */ -UNIV_INLINE -char* -fil_space_name( -/*===========*/ - fil_space_t* space) /*!< in: space */ -{ - return (space->name); -} - -/*******************************************************************//** -Return space flags */ -UNIV_INLINE -ulint -fil_space_flags( -/*===========*/ - fil_space_t* space) /*!< in: space */ -{ - return (space->flags); -} - /*******************************************************************//** Return page type name */ UNIV_INLINE diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index 73df69beb90..8b2449983df 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -171,12 +171,15 @@ fil_compress_page( /* If error we leave the actual page as it was */ #ifndef UNIV_PAGECOMPRESS_DEBUG - if (space->printed_compression_failure == false) { + if (space && !space->printed_compression_failure) { + space->printed_compression_failure = true; #endif ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu rt %d write %lu.", - space_id, fil_space_name(space), len, err, write_size); - space->printed_compression_failure = true; + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + err, write_size); #ifndef UNIV_PAGECOMPRESS_DEBUG } #endif @@ -192,11 +195,14 @@ fil_compress_page( buf, len, out_buf+header_len, &write_size, lzo_mem); if (err != LZO_E_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space->printed_compression_failure == false) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu err %d write_size %lu.", - space_id, fil_space_name(space), len, err, write_size); + if (space && !space->printed_compression_failure) { space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + err, write_size); } srv_stats.pages_page_compression_error.inc(); @@ -221,11 +227,14 @@ fil_compress_page( (size_t)write_size); if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { - if (space->printed_compression_failure == false) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu err %d write_size %lu", - space_id, fil_space_name(space), len, err, out_pos); + if (space && !space->printed_compression_failure) { space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + err, out_pos); } srv_stats.pages_page_compression_error.inc(); @@ -252,11 +261,14 @@ fil_compress_page( 0); if (err != BZ_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space->printed_compression_failure == false) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu err %d write_size %lu.", - space_id, fil_space_name(space), len, err, write_size); + if (space && !space->printed_compression_failure) { space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + err, write_size); } srv_stats.pages_page_compression_error.inc(); @@ -279,11 +291,14 @@ fil_compress_page( (size_t*)&write_size); if (cstatus != SNAPPY_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space->printed_compression_failure == false) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space %lu name %s len %lu err %d write_size %lu.", - space_id, fil_space_name(space), len, (int)cstatus, write_size); + if (space && !space->printed_compression_failure) { space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " err %d write_size " ULINTPF ".", + space->id, space->name, len, + (int)cstatus, write_size); } srv_stats.pages_page_compression_error.inc(); @@ -302,13 +317,13 @@ fil_compress_page( /* If error we leave the actual page as it was */ if (space && !space->printed_compression_failure) { - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " - ULINTPF " name %s len " ULINTPF - " rt %d write " ULINTPF ".", - space->id, space->name, len, err, - write_size); space->printed_compression_failure = true; + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space " ULINTPF + " name %s len " ULINTPF + " rt %d write_size " ULINTPF ".", + space->id, space->name, len, + err, write_size); } srv_stats.pages_page_compression_error.inc(); diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index fe7cc60d1e4..d73a68d9d34 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2013, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1460,14 +1460,6 @@ fil_get_next_space_safe( #endif /* UNIV_INNOCHECKSUM */ -/*******************************************************************//** -Return space flags */ -UNIV_INLINE -ulint -fil_space_flags( -/*===========*/ - fil_space_t* space); /*!< in: space */ - /****************************************************************//** Does error handling when a file operation fails. @return TRUE if we should retry the operation */ diff --git a/storage/xtradb/include/fil0fil.ic b/storage/xtradb/include/fil0fil.ic index b79167baead..6c2504c9f8c 100644 --- a/storage/xtradb/include/fil0fil.ic +++ b/storage/xtradb/include/fil0fil.ic @@ -26,28 +26,6 @@ Created 31/03/2015 Jan Lindström #ifndef fil0fil_ic #define fil0fil_ic -/*******************************************************************//** -Return space name */ -UNIV_INLINE -char* -fil_space_name( -/*===========*/ - fil_space_t* space) /*!< in: space */ -{ - return (space->name); -} - -/*******************************************************************//** -Return space flags */ -UNIV_INLINE -ulint -fil_space_flags( -/*===========*/ - fil_space_t* space) /*!< in: space */ -{ - return (space->flags); -} - /*******************************************************************//** Return page type name */ UNIV_INLINE From 7d0ac3ade7fb9f1276e87faa7099832d01329200 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 24 Apr 2017 13:02:08 +1000 Subject: [PATCH 51/52] MDEV-12488: Remove type mismatch in InnoDB printf-like calls To fix OSX error: /Users/travis/build/grooverdan/mariadb-server/storage/xtradb/sync/sync0arr.cc:530:5: warning: format specifies type 'unsigned long' but the argument has type 'os_thread_id_t' (aka '_opaque_pthread_t *') [-Wformat] mutex->thread_id, ^~~~~~~~~~~~~~~~ Signed-off-by: Daniel Black --- storage/xtradb/sync/sync0arr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/xtradb/sync/sync0arr.cc b/storage/xtradb/sync/sync0arr.cc index ae8032da167..134d16ae58e 100644 --- a/storage/xtradb/sync/sync0arr.cc +++ b/storage/xtradb/sync/sync0arr.cc @@ -527,7 +527,7 @@ sync_array_cell_print( "waiters flag " ULINTPF "\n", (void*) mutex, mutex->cmutex_name, (ulong) mutex->lock_word, - mutex->thread_id, + os_thread_pf(mutex->thread_id), mutex->file_name, mutex->line, mutex->waiters); } From 97e0c260dc8273f809915505f8dfdccd948b4b99 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Tue, 25 Apr 2017 15:25:10 +0530 Subject: [PATCH 52/52] Fix Galera tests failures on 10.1 and 10.2 When we build server out of git directory , we did not copy wsrep_sst_common into build-dir. This causes galera/wsrep tests to fail --- scripts/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 148dddccf30..b758e9c0d05 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -291,6 +291,7 @@ ELSE() IF(WITH_WSREP) SET(WSREP_SCRIPTS wsrep_sst_mysqldump + wsrep_sst_common wsrep_sst_rsync wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2