Search code examples
mysqlamazon-web-servicesamazon-rdsdatabase-replicationmysql-8.0

Why MySQL database replica does not replicate when replica has bigint key and master has int key?


I try to change the primary key size or another field from int to bigint.

MySQL manual tells me that this type of convert is available (from int to bigint), but my replica gets an error:

Column 1 of table 'Items' cannot be converted from type 'int' to type 'bigint(20)'

As example master table

create table Items(
 id int auto_increment,
 quantity int null
)

Replica table

create table Items(
 id int auto_increment,
 quantity bigint(20) null
)

MySQL version 8.0.15

Why MySQL broke replication when replica has type bigint over int on master?


Solution

  • I found the solution. Problem with config field slave_type_conversions

    By default, MySQL has empty slave_type_conversions this means that all columns in the source and target tables must be of the same types.

    I changed this value to ALL_LOSSY,ALL_NON_LOSSY and MySQL allowed conversion to bigint