Commit 3fee1b44 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.5 into 10.6

parents fc78b253 599c4d9a
......@@ -90,7 +90,6 @@ C_MODE_START
#define MY_THREADSAFE 2048U /* my_seek(): lock fd mutex */
#define MY_SYNC 4096U /* my_copy(): sync dst file */
#define MY_SYNC_DIR 32768U /* my_create/delete/rename: sync directory */
#define MY_SYNC_FILESIZE 65536U /* my_sync(): safe sync when file is extended */
#define MY_THREAD_SPECIFIC 0x10000U /* my_malloc(): thread specific */
/* Tree that should delete things automatically */
#define MY_TREE_WITH_DELETE 0x40000U
......
This diff is collapsed.
......@@ -267,13 +267,194 @@ INSERT INTO t1 VALUES('aa');
SET column_compression_threshold=DEFAULT;
DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo # MDEV-31724 Compressed varchar values lost on joins when sorting on columns from joined table(s)
--echo #
CREATE TABLE t1 (
id int(10) unsigned not null,
txt varchar(5000) COMPRESSED NOT NULL DEFAULT '',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;
CREATE TABLE t2 (
id int(10) unsigned not null,
n1 bigint(20) NOT NULL,
n2 bigint(20) NOT NULL,
n3 bigint(20) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin;
INSERT INTO t1 VALUES
(1, 'short string < 100 chars'),
(2, 'long string = 99 chars '),
(3, 'long string = 100 chars !'),
(4, 'long string = 101 chars !');
INSERT INTO t2 VALUES
(1, 24, 1, 1),
(2, 99, 2, 2),
(3, 100, 3, 3),
(4, 101, 4, 4);
SELECT txt, v.* FROM t1 LEFT JOIN t2 v ON t1.id = v.id;
SELECT txt, v.* FROM t1 LEFT JOIN t2 v ON t1.id = v.id ORDER BY v.n1;
SELECT txt, v.* FROM t1 JOIN t2 v ON t1.id = v.id;
SELECT txt, v.* FROM t1 JOIN t2 v ON t1.id = v.id ORDER BY v.n1;
DROP TABLE t1, t2;
CREATE OR REPLACE TABLE t1 (
id INT NOT NULL PRIMARY KEY,
txt varchar(5000) COMPRESSED NOT NULL DEFAULT ''
) CHARSET=utf8mb3;
INSERT INTO t1 VALUES
(1, REPEAT('a', 10)),
(2, REPEAT('b', 99)),
(3, REPEAT('c', 100)),
(4, REPEAT('d', 121));
--replace_column 2 <sysdate>
--sorted_result
SELECT txt, sysdate(6) FROM t1 ORDER BY 2;
DROP TABLE t1;
DELIMITER $$;
CREATE FUNCTION f1(imax INT, jmax INT) RETURNS TEXT
BEGIN
DECLARE res TEXT DEFAULT 'x';
FOR i IN 0..imax
DO
FOR j IN 0..jmax
DO
SET res=CONCAT(res, ' ', i, ' ', j);
END FOR;
END FOR;
RETURN res;
END;
$$
DELIMITER ;$$
# Let's override the default threshold (100) to force
# comression for VARCHAR1+MB, for example, for:
# VARCHAR(80) CHARACTER SET utf8mb3
SET @@column_compression_threshold=32;
--echo # VARCHAR1, 8bit, truncation
CREATE TABLE t1 (a VARCHAR(254) COMPRESSED CHARACTER SET latin1);
INSERT INTO t1 VALUES (f1(6,6));
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
FLUSH STATUS;
ALTER IGNORE TABLE t1 MODIFY a VARCHAR(4) COMPRESSED CHARACTER SET latin1;
SHOW STATUS LIKE 'Column%compressions';
SELECT LENGTH(a), a FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(254) COMPRESSED CHARACTER SET latin1);
INSERT INTO t1 VALUES (REPEAT('a',254));
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
FLUSH STATUS;
ALTER IGNORE TABLE t1 MODIFY a VARCHAR(4) COMPRESSED CHARACTER SET latin1;
SHOW STATUS LIKE 'Column%compressions';
SELECT LENGTH(a), a FROM t1;
DROP TABLE t1;
--echo # VARCHAR1, 8bit, no truncation
CREATE TABLE t1 (a VARCHAR(250) COMPRESSED CHARACTER SET latin1);
INSERT INTO t1 VALUES (f1(6,6));
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
FLUSH STATUS;
ALTER IGNORE TABLE t1 MODIFY a VARCHAR(254) COMPRESSED CHARACTER SET latin1;
SHOW STATUS LIKE 'Column%compressions';
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
DROP TABLE t1;
--echo # VARCHAR2, 8bit, truncation
CREATE TABLE t1 (a VARCHAR(32000) COMPRESSED CHARACTER SET latin1);
INSERT INTO t1 VALUES (f1(31,31));
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
FLUSH STATUS;
ALTER IGNORE TABLE t1 MODIFY a VARCHAR(256) COMPRESSED CHARACTER SET latin1;
SHOW STATUS LIKE 'Column%compressions';
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
DROP TABLE t1;
--echo # VARCHAR2, 8bit, no truncation
CREATE TABLE t1 (a VARCHAR(32000) COMPRESSED CHARACTER SET latin1);
INSERT INTO t1 VALUES (f1(31,31));
SELECT LENGTH(a), LEFT(a,30), RIGHT(a, 30) FROM t1;
FLUSH STATUS;
ALTER IGNORE TABLE t1 MODIFY a VARCHAR(32001) COMPRESSED CHARACTER SET latin1;
SHOW STATUS LIKE 'Column%compressions';
SELECT LENGTH(a), LEFT(a,30), RIGHT(a, 30) FROM t1;
DROP TABLE t1;
--echo # VARCHAR1, multi-byte, truncation
CREATE TABLE t1 (a VARCHAR(80) COMPRESSED CHARACTER SET utf8mb3);
INSERT INTO t1 VALUES (f1(3,3));
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
FLUSH STATUS;
ALTER IGNORE TABLE t1 MODIFY a VARCHAR(1) COMPRESSED CHARACTER SET utf8mb3;
SHOW STATUS LIKE 'Column%compressions';
SELECT LENGTH(a), a FROM t1;
DROP TABLE t1;
--echo # VARCHAR1, multi-byte, no truncation
CREATE TABLE t1 (a VARCHAR(80) COMPRESSED CHARACTER SET utf8mb3);
INSERT INTO t1 VALUES (f1(3,3));
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
FLUSH STATUS;
ALTER IGNORE TABLE t1 MODIFY a VARCHAR(81) COMPRESSED CHARACTER SET utf8mb3;
SHOW STATUS LIKE 'Column%compressions';
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
DROP TABLE t1;
--echo # VARCHAR2, multi-byte, truncation
CREATE TABLE t1 (a VARCHAR(10000) COMPRESSED CHARACTER SET utf8mb3);
INSERT INTO t1 VALUES (f1(31,31));
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
FLUSH STATUS;
ALTER IGNORE TABLE t1 MODIFY a VARCHAR(256) COMPRESSED CHARACTER SET utf8mb3;
SHOW STATUS LIKE 'Column%compressions';
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
DROP TABLE t1;
--echo # VARCHAR2, multi-byte, no truncation
CREATE TABLE t1 (a VARCHAR(10000) COMPRESSED CHARACTER SET utf8mb3);
INSERT INTO t1 VALUES (f1(31,31));
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
FLUSH STATUS;
ALTER IGNORE TABLE t1 MODIFY a VARCHAR(10001) COMPRESSED CHARACTER SET utf8mb3;
SHOW STATUS LIKE 'Column%compressions';
SELECT LENGTH(a), LEFT(a,30), RIGHT(a,30) FROM t1;
DROP TABLE t1;
SET @@column_compression_threshold=DEFAULT;
DROP FUNCTION f1;
--echo #
--echo # MDEV-24797 Column Compression - ERROR 1265 (01000): Data truncated for column
--echo #
CREATE TABLE t1 (a VARCHAR(500) COMPRESSED CHARACTER SET utf8mb3) ENGINE=MyISAM;
INSERT INTO t1 SET a=REPEAT('x',127);
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(500) COMPRESSED CHARACTER SET utf8mb3) ENGINE=InnoDB;
INSERT INTO t1 SET a=REPEAT('x',127);
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
DROP TABLE t1;
--echo #
--echo # Start of 10.5 tests
--echo # End of 10.4 tests
--echo #
--echo #
......
......@@ -17,12 +17,15 @@ SELECT LENGTH(@@global.gtid_binlog_state) > 1;
LENGTH(@@global.gtid_binlog_state) > 1
1
connection node_1;
SELECT COUNT(*) AS EXPECT_1 FROM t1;
EXPECT_1
1
gtid_binlog_state_equal
0
connection node_2;
SELECT COUNT(*) AS EXPECT_0 FROM t1;
EXPECT_0
0
SELECT COUNT(*) AS EXPECT_1 FROM t1;
EXPECT_1
1
gtid_binlog_state_equal
0
#cleanup
......
connection node_2;
connection node_1;
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
create user repl@'%' identified by 'repl';
grant all on *.* to repl@'%';
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
connection node_1;
connection node_2;
connection node_2;
START SLAVE;
connection node_3;
CREATE TABLE t1 (id bigint primary key, msg varchar(100)) engine=innodb;
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
EXPECT_10000
10000
connection node_2;
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
EXPECT_10000
10000
connection node_1;
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
EXPECT_10000
10000
connection node_2;
# Verify that graceful shutdown succeeds.
# Force SST
connection node_1;
# Waiting until node_2 is not part of cluster anymore
connection node_2;
# Start node_2 again
¤ Wait until node_2 is back on cluster
connection node_2;
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
EXPECT_10000
10000
connection node_1;
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
EXPECT_10000
10000
connection node_3;
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
EXPECT_10000
10000
connection node_3;
drop table t1;
connection node_2;
connection node_1;
connection node_3;
CREATE TABLE t1 (id bigint primary key, msg varchar(100)) engine=innodb;
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
EXPECT_10000
10000
connection node_2;
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
EXPECT_10000
10000
connection node_1;
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
EXPECT_10000
10000
connection node_2;
# Verify that graceful shutdown succeeds.
# Force SST
connection node_1;
# Waiting until node_2 is not part of cluster anymore
connection node_3;
SELECT COUNT(*) AS EXPECT_20000 FROM t1;
EXPECT_20000
20000
connection node_2;
# Start node_2 again
¤ Wait until node_2 is back on cluster
connection node_2;
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_20000 FROM t1;
EXPECT_20000
20000
connection node_1;
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_20000 FROM t1;
EXPECT_20000
20000
connection node_3;
SELECT COUNT(*) AS EXPECT_20000 FROM t1;
EXPECT_20000
20000
connection node_3;
drop table t1;
connection node_2;
connection node_1;
connection node_2;
STOP SLAVE;
RESET SLAVE ALL;
connection node_3;
RESET MASTER;
connection node_1;
disconnect node_3;
disconnect node_2;
disconnect node_1;
# End of test
......@@ -4,3 +4,4 @@
log-bin=mysqld-bin
log-slave-updates
binlog-format=ROW
wsrep-replicate-myisam=ON
......@@ -44,12 +44,20 @@ SELECT LENGTH(@@global.gtid_binlog_state) > 1;
--let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) AS EXPECT_1 FROM t1;
--disable_query_log
--eval SELECT '$gtid_binlog_state_node1' = @@global.gtid_binlog_state AS gtid_binlog_state_equal;
--enable_query_log
--connection node_2
SELECT COUNT(*) AS EXPECT_0 FROM t1;
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) AS EXPECT_1 FROM t1;
--disable_query_log
--eval SELECT '$gtid_binlog_state_node1' = @@global.gtid_binlog_state AS gtid_binlog_state_equal;
......@@ -59,8 +67,6 @@ SELECT COUNT(*) AS EXPECT_0 FROM t1;
--connection node_3
DROP TABLE t1;
--sleep 1
--connection node_1
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
......
!include ../galera_2nodes_as_slave.cnf
[mysqld]
wsrep-debug=1
[mysqld.1]
server_id=15
wsrep_gtid_mode=1
wsrep_gtid_domain_id=16
gtid_domain_id=11
gtid_strict_mode=1
[mysqld.2]
skip-slave-start=OFF
server_id=15
wsrep_gtid_mode=1
wsrep_gtid_domain_id=16
gtid_domain_id=11
gtid_strict_mode=1
#
# Test Galera as a replica to a MySQL async replication
#
# The galera/galera_2node_slave.cnf describes the setup of the nodes
#
--source include/big_test.inc
--source include/force_restart.inc
--source include/galera_cluster.inc
--source include/have_sequence.inc
# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it
# we open the node_3 connection here
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
create user repl@'%' identified by 'repl';
grant all on *.* to repl@'%';
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
--let $node_1 = node_1
--let $node_2 = node_2
--source include/auto_increment_offset_save.inc
--connection node_2
--disable_query_log
--eval CHANGE MASTER TO master_host='127.0.0.1', master_user='repl', master_password='repl', master_port=$NODE_MYPORT_3, master_use_gtid=slave_pos;
--enable_query_log
START SLAVE;
--connection node_3
CREATE TABLE t1 (id bigint primary key, msg varchar(100)) engine=innodb;
--disable_query_log
INSERT INTO t1 SELECT seq, 'test' from seq_1_to_10000;
--enable_query_log
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10000 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
--connection node_1
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10000 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
--connection node_2
--echo # Verify that graceful shutdown succeeds.
--source include/shutdown_mysqld.inc
--echo # Force SST
--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
--connection node_1
--echo # Waiting until node_2 is not part of cluster anymore
--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
--connection node_2
--echo # Start node_2 again
--source include/start_mysqld.inc
--echo ¤ Wait until node_2 is back on cluster
--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
--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
--source include/wait_condition.inc
--connection node_2
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
--connection node_1
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
--connection node_3
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
#
# Cleanup
#
--connection node_3
drop table t1;
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
--connection node_1
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
#
# Case 2 : While slave is down add writes to master
#
--connection node_3
CREATE TABLE t1 (id bigint primary key, msg varchar(100)) engine=innodb;
--disable_query_log
INSERT INTO t1 SELECT seq, 'test' from seq_1_to_10000;
--enable_query_log
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10000 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
--connection node_1
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10000 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
SELECT COUNT(*) AS EXPECT_10000 FROM t1;
--connection node_2
--echo # Verify that graceful shutdown succeeds.
--source include/shutdown_mysqld.inc
--echo # Force SST
--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
--connection node_1
--echo # Waiting until node_2 is not part of cluster anymore
--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
# Add writes to master
--connection node_3
--disable_query_log
INSERT INTO t1 SELECT seq, 'test' from seq_20001_to_30000;
--enable_query_log
SELECT COUNT(*) AS EXPECT_20000 FROM t1;
--connection node_2
--echo # Start node_2 again
--source include/start_mysqld.inc
--echo ¤ Wait until node_2 is back on cluster
--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
--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
--source include/wait_condition.inc
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 20000 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
SELECT COUNT(*) AS EXPECT_20000 FROM t1;
--connection node_1
--let $wait_condition = SELECT COUNT(*) = 20000 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
SELECT COUNT(*) AS EXPECT_20000 FROM t1;
--connection node_3
SELECT COUNT(*) AS EXPECT_20000 FROM t1;
#
# Cleanup
#
--connection node_3
drop table t1;
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
--connection node_1
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc
--connection node_2
STOP SLAVE;
RESET SLAVE ALL;
--connection node_3
RESET MASTER;
--connection node_1
--disconnect node_3
--source include/auto_increment_offset_restore.inc
--source include/galera_end.inc
--echo # End of test
......@@ -263,13 +263,34 @@ BEGIN;
START SLAVE IO_THREAD;
--source include/wait_for_slave_io_to_start.inc
# The following test sets the stop coordinate is set to inside the first event
# The following test sets the stop coordinate to inside the first event
# of a relay log that holds events of a transaction started in an earlier log.
# Peek the stop position in the middle of trx1, not even on a event boundary.
--let $pos_until=255
--let $file_rl=slave-relay-bin.000003
--let $binlog_file=$file_rl
# Wait for the IO thread to write the trx1 to the relaylog before querying it.
# (wait_for_slave_param.inc isn't flexible enough, so do it manually.)
--let $continue= 1
--let $count=600
while ($continue)
{
--let $cur_file= query_get_value(SHOW SLAVE STATUS, 'Master_Log_File', 1)
--let $cur_pos= query_get_value(SHOW SLAVE STATUS, 'Read_Master_Log_Pos', 1)
--let $continue= `SELECT '$cur_file' = '$fil_1' AND $cur_pos < $pos_trx1`
if ($continue)
{
--dec $count
if (!$count)
{
--echo **** ERROR: timeout waiting for Read_Master_Log_Pos($cur_pos) >= $pos_trx1 (file='$cur_file') ****"
--die Timeout waiting for IO thread to write master events to the relaylog
}
--sleep 0.1
}
}
--let $pos_xid=508
--let $info= query_get_value(SHOW RELAYLOG EVENTS IN '$file_rl' FROM $pos_xid LIMIT 1, Info, 1)
......
......@@ -49,13 +49,6 @@ void thr_set_sync_wait_callback(void (*before_wait)(void),
(which is correct behaviour, if we know that the other thread synced the
file before closing)
MY_SYNC_FILESIZE is useful when syncing a file after it has been extended.
On Linux, fdatasync() on ext3/ext4 file systems does not properly flush
to disk the inode data required to preserve the added data across a crash
(this looks to be a bug). But when a file is extended, inode data will most
likely need flushing in any case, so passing MY_SYNC_FILESIZE as flags
is not likely to be any slower, and will be crash safe on Linux ext3/ext4.
RETURN
0 ok
-1 error
......@@ -88,12 +81,8 @@ int my_sync(File fd, myf my_flags)
DBUG_PRINT("info",("fcntl(F_FULLFSYNC) failed, falling back"));
#endif
#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
if (!(my_flags & MY_SYNC_FILESIZE))
res= fdatasync(fd);
else
{
#endif
#if defined(HAVE_FSYNC)
#elif defined(HAVE_FSYNC)
res= fsync(fd);
if (res == -1 && errno == ENOLCK)
res= 0; /* Result Bug in Old FreeBSD */
......@@ -102,9 +91,6 @@ int my_sync(File fd, myf my_flags)
#else
#error Cannot find a way to sync a file, durability in danger
res= 0; /* No sync (strange OS) */
#endif
#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
}
#endif
} while (res == -1 && errno == EINTR);
......
......@@ -393,8 +393,7 @@ static bool backup_block_commit(THD *thd)
if (mysql_bin_log.is_open())
{
mysql_mutex_lock(mysql_bin_log.get_log_lock());
mysql_file_sync(mysql_bin_log.get_log_file()->file,
MYF(MY_WME|MY_SYNC_FILESIZE));
mysql_file_sync(mysql_bin_log.get_log_file()->file, MYF(MY_WME));
mysql_mutex_unlock(mysql_bin_log.get_log_lock());
}
thd->clear_error();
......
......@@ -531,6 +531,40 @@ static void do_expand_string(Copy_field *copy)
}
/*
Copy from a Field_varstring with length_bytes==1
into another Field_varstring with length_bytes==1
when the target column is not shorter than the source column.
We don't need to calculate the prefix in this case. It works for
- non-compressed and compressed columns
- single byte and multi-byte character sets
*/
static void do_varstring1_no_truncation(Copy_field *copy)
{
uint length= (uint) *(uchar*) copy->from_ptr;
DBUG_ASSERT(length <= copy->to_length - 1);
*(uchar*) copy->to_ptr= (uchar) length;
memcpy(copy->to_ptr+1, copy->from_ptr + 1, length);
}
/*
Copy from a Field_varstring with length_bytes==2
into another Field_varstring with length_bytes==2
when the target column is not shorter than the source column.
We don't need to calculate the prefix in this case. It works for
- non-compressed and compressed columns
- single byte and multi-byte character sets
*/
static void do_varstring2_no_truncation(Copy_field *copy)
{
uint length= uint2korr(copy->from_ptr);
DBUG_ASSERT(length <= copy->to_length - HA_KEY_BLOB_LENGTH);
int2store(copy->to_ptr, length);
memcpy(copy->to_ptr + HA_KEY_BLOB_LENGTH,
copy->from_ptr + HA_KEY_BLOB_LENGTH, length);
}
static void do_varstring1(Copy_field *copy)
{
uint length= (uint) *(uchar*) copy->from_ptr;
......@@ -775,6 +809,21 @@ Field::Copy_func *Field_varstring::get_copy_func(const Field *from) const
length_bytes != ((const Field_varstring*) from)->length_bytes ||
!compression_method() != !from->compression_method())
return do_field_string;
if (field_length >= from->field_length)
return length_bytes == 1 ? do_varstring1_no_truncation :
do_varstring2_no_truncation;
if (compression_method())
{
/*
Truncation is going to happen, so we need to calculate prefixes.
Can't calculate prefixes directly on compressed data,
need to go through val_str() to uncompress.
*/
return do_field_string;
}
return length_bytes == 1 ?
(from->charset()->mbmaxlen == 1 ? do_varstring1 : do_varstring1_mb) :
(from->charset()->mbmaxlen == 1 ? do_varstring2 : do_varstring2_mb);
......
......@@ -3943,7 +3943,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
bytes_written+= description_event_for_queue->data_written;
}
if (flush_io_cache(&log_file) ||
mysql_file_sync(log_file.file, MYF(MY_WME|MY_SYNC_FILESIZE)))
mysql_file_sync(log_file.file, MYF(MY_WME)))
goto err;
my_off_t offset= my_b_tell(&log_file);
......@@ -3981,7 +3981,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
strlen(log_file_name)) ||
my_b_write(&index_file, (uchar*) "\n", 1) ||
flush_io_cache(&index_file) ||
mysql_file_sync(index_file.file, MYF(MY_WME|MY_SYNC_FILESIZE)))
mysql_file_sync(index_file.file, MYF(MY_WME)))
goto err;
#ifdef HAVE_REPLICATION
......@@ -4121,7 +4121,7 @@ static bool copy_up_file_and_fill(IO_CACHE *index_file, my_off_t offset)
}
/* The following will either truncate the file or fill the end with \n' */
if (mysql_file_chsize(file, offset - init_offset, '\n', MYF(MY_WME)) ||
mysql_file_sync(file, MYF(MY_WME|MY_SYNC_FILESIZE)))
mysql_file_sync(file, MYF(MY_WME)))
goto err;
/* Reset data in old index cache */
......@@ -4917,7 +4917,7 @@ int MYSQL_BIN_LOG::sync_purge_index_file()
if (unlikely((error= flush_io_cache(&purge_index_file))) ||
unlikely((error= my_sync(purge_index_file.file,
MYF(MY_WME | MY_SYNC_FILESIZE)))))
MYF(MY_WME)))))
DBUG_RETURN(error);
DBUG_RETURN(error);
......@@ -5629,7 +5629,7 @@ bool MYSQL_BIN_LOG::flush_and_sync(bool *synced)
if (sync_period && ++sync_counter >= sync_period)
{
sync_counter= 0;
err= mysql_file_sync(fd, MYF(MY_WME|MY_SYNC_FILESIZE));
err= mysql_file_sync(fd, MYF(MY_WME));
if (synced)
*synced= 1;
#ifndef DBUG_OFF
......@@ -6409,7 +6409,7 @@ MYSQL_BIN_LOG::write_state_to_file()
log_inited= false;
if ((err= end_io_cache(&cache)))
goto err;
if ((err= mysql_file_sync(file_no, MYF(MY_WME|MY_SYNC_FILESIZE))))
if ((err= mysql_file_sync(file_no, MYF(MY_WME))))
goto err;
goto end;
......@@ -10167,7 +10167,7 @@ bool MYSQL_BIN_LOG::truncate_and_remove_binlogs(const char *file_name,
error= mysql_file_chsize(index_file.file, index_file_offset, '\n',
MYF(MY_WME));
if (!error)
error= mysql_file_sync(index_file.file, MYF(MY_WME|MY_SYNC_FILESIZE));
error= mysql_file_sync(index_file.file, MYF(MY_WME));
if (error)
{
sql_print_error("Failed to truncate binlog index "
......@@ -10209,7 +10209,7 @@ bool MYSQL_BIN_LOG::truncate_and_remove_binlogs(const char *file_name,
/* Change binlog file size to truncate_pos */
error= mysql_file_chsize(file, pos, 0, MYF(MY_WME));
if (!error)
error= mysql_file_sync(file, MYF(MY_WME|MY_SYNC_FILESIZE));
error= mysql_file_sync(file, MYF(MY_WME));
if (error)
{
sql_print_error("Failed to truncate the "
......
......@@ -28,6 +28,10 @@
#include "rpl_rli.h"
#include "slave.h"
#include "log_event.h"
#ifdef WITH_WSREP
#include "wsrep_mysqld.h" // wsrep_thd_is_local
#include "wsrep_trans_observer.h" // wsrep_start_trx_if_not_started
#endif
const LEX_CSTRING rpl_gtid_slave_state_table_name=
{ STRING_WITH_LEN("gtid_slave_pos") };
......@@ -693,10 +697,18 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id,
#ifdef WITH_WSREP
/*
Updates in slave state table should not be appended to galera transaction
writeset.
We should replicate local gtid_slave_pos updates to other nodes.
In applier we should not append them to galera writeset.
*/
if (WSREP_ON_ && wsrep_thd_is_local(thd))
{
thd->wsrep_ignore_table= false;
wsrep_start_trx_if_not_started(thd);
}
else
{
thd->wsrep_ignore_table= true;
}
#endif
if (!in_transaction)
......@@ -862,9 +874,20 @@ rpl_slave_state::gtid_delete_pending(THD *thd,
#ifdef WITH_WSREP
/*
Updates in slave state table should not be appended to galera transaction
writeset.
We should replicate local gtid_slave_pos updates to other nodes.
In applier we should not append them to galera writeset.
*/
if (WSREP_ON_ && wsrep_thd_is_local(thd) &&
thd->wsrep_cs().state() != wsrep::client_state::s_none)
{
if (thd->wsrep_trx().active() == false)
{
if (thd->wsrep_next_trx_id() == WSREP_UNDEFINED_TRX_ID)
thd->set_query_id(next_query_id());
wsrep_start_transaction(thd, thd->wsrep_next_trx_id());
}
thd->wsrep_ignore_table= false;
}
thd->wsrep_ignore_table= true;
#endif
......
......@@ -5563,6 +5563,8 @@ pthread_handler_t handle_slave_sql(void *arg)
mysql_mutex_unlock(&rli->data_lock);
#ifdef WITH_WSREP
wsrep_open(thd);
if (WSREP_ON_)
wsrep_wait_ready(thd);
if (wsrep_before_command(thd))
{
WSREP_WARN("Slave SQL wsrep_before_command() failed");
......
/* Copyright (c) 2008, 2022 Codership Oy <http://www.codership.com>
/* Copyright (c) 2008, 2023 Codership Oy <http://www.codership.com>
Copyright (c) 2020, 2022, MariaDB
This program is free software; you can redistribute it and/or modify
......@@ -3742,6 +3742,30 @@ bool wsrep_consistency_check(THD *thd)
return thd->wsrep_consistency_check == CONSISTENCY_CHECK_RUNNING;
}
// Wait until wsrep has reached ready state
void wsrep_wait_ready(THD *thd)
{
mysql_mutex_lock(&LOCK_wsrep_ready);
while(!wsrep_ready)
{
WSREP_INFO("Waiting to reach ready state");
mysql_cond_wait(&COND_wsrep_ready, &LOCK_wsrep_ready);
}
WSREP_INFO("ready state reached");
mysql_mutex_unlock(&LOCK_wsrep_ready);
}
void wsrep_ready_set(bool ready_value)
{
WSREP_DEBUG("Setting wsrep_ready to %d", ready_value);
mysql_mutex_lock(&LOCK_wsrep_ready);
wsrep_ready= ready_value;
// Signal if we have reached ready state
if (wsrep_ready)
mysql_cond_signal(&COND_wsrep_ready);
mysql_mutex_unlock(&LOCK_wsrep_ready);
}
/*
Commit an empty transaction.
......
/* Copyright 2008-2022 Codership Oy <http://www.codership.com>
/* Copyright 2008-2023 Codership Oy <http://www.codership.com>
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
......@@ -597,6 +597,8 @@ enum wsrep::streaming_context::fragment_unit wsrep_fragment_unit(ulong unit);
wsrep::key wsrep_prepare_key_for_toi(const char* db, const char* table,
enum wsrep::key::type type);
void wsrep_wait_ready(THD *thd);
void wsrep_ready_set(bool ready_value);
#else /* !WITH_WSREP */
/* These macros are needed to compile MariaDB without WSREP support
......
/* Copyright 2010 Codership Oy <http://www.codership.com>
/* Copyright 2010-2023 Codership Oy <http://www.codership.com>
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
......@@ -22,8 +22,6 @@
#include "wsrep_api.h"
#include "wsrep/server_state.hpp"
my_bool wsrep_ready_set (my_bool x);
ssize_t wsrep_sst_prepare (void** msg);
wsrep_cb_status wsrep_sst_donate_cb (void* app_ctx,
void* recv_ctx,
......
......@@ -347,6 +347,7 @@ void Wsrep_server_service::log_state_change(
case Wsrep_server_state::s_synced:
wsrep_ready= TRUE;
WSREP_INFO("Synchronized with group, ready for connections");
wsrep_ready_set(true);
/* fall through */
case Wsrep_server_state::s_joined:
case Wsrep_server_state::s_donor:
......@@ -354,16 +355,16 @@ void Wsrep_server_service::log_state_change(
break;
case Wsrep_server_state::s_connected:
wsrep_cluster_status= "non-Primary";
wsrep_ready= FALSE;
wsrep_ready_set(false);
wsrep_connected= TRUE;
break;
case Wsrep_server_state::s_disconnected:
wsrep_ready= FALSE;
wsrep_ready_set(false);
wsrep_connected= FALSE;
wsrep_cluster_status= "Disconnected";
break;
default:
wsrep_ready= FALSE;
wsrep_ready_set(false);
wsrep_cluster_status= "non-Primary";
break;
}
......
Subproject commit 7dafce8403d4088ddc8748f2e08eae13b1f225b6
Subproject commit 173693f2eeb61054424233fe85fde4086bed36be
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment