utf8 on master and utf8mb4 on slave leads to "cannot be converted from type" error
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
MySQL Server |
Unknown
|
Unknown
|
||||
Percona Server moved to https://jira.percona.com/projects/PS | Status tracked in 5.7 | |||||
5.6 |
Triaged
|
Medium
|
Unassigned | |||
5.7 |
Triaged
|
Medium
|
Unassigned |
Bug Description
Description:
Similar to MySQL bug #71111 (https:/
If a table has utf8 character set on master and utf8mb4 on slave replication fails with error " Column 1 of table 'test.t1' cannot be converted from type 'varchar(765)' to type 'varchar(255)'"
Workaround:
--slave-
or use statement-based replication
How to repeat:
$cat rpl_bug-master.opt
--innodb-
$cat rpl_bug-slave.opt
--innodb-
$cat rpl_bug.test
--source include/
CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT primary key,
`bug` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=
insert into t1 values(1, 'Света тестирует баг');
--sync_
ALTER TABLE t1 CHARSET=utf8mb4 COLLATE=
ALTER TABLE t1 MODIFY COLUMN `bug` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL;
show create table t1;
connection master;
insert into t1 values(2, 'Света тестирует баг');
--sync_
no longer affects: | percona-server/5.5 |
no longer affects: | percona-server/5.7 |
tags: | added: upstream |
Test case can be even simple as you do not use the foreign characters to reproduce the problem. You can just use:
insert into t1 values (1, 'abc')
and it will be the same error. It is not what you inserted that causes the error, but that the row has been widened on the same. The unsupported chars will be converted as "?" anyway, for example:
insert into t1 values (2, _utf8mb4 x'F09D8C86')
will be converted as "2,?" in the master table and will be replicated as such on slave.