当前位置:网站首页>Tidb CDC synchronization of features not available in MySQL to MySQL

Tidb CDC synchronization of features not available in MySQL to MySQL

2022-06-11 17:33:00 On the way to data communication

One 、 background

In order to ensure tidb Stable operation of , We are tidb The backend of is connected to a mysql, however tidb There are also some mysql Features not found in , At this time of the cdc What will happen , Here are some of the common features to be tested

Two 、 The experimental steps

1. Refresh binary

#  Execution location : The downstream mysql
#  Purpose : To make it easier to see what is actually written to the binary 
flush logs

2. Create a SHARD_ROW_ID_BITS Table of features

create table write_hot_3 (id bigint(20) not null, z_name varchar(20), z_info varchar(30),unique key(id)) SHARD_ROW_ID_BITS = 4
PRE_SPLIT_REGIONS=3

create table write_hot_2(id bigint(20) not null auto_random primary key,z_name varchar(20),z_info varchar(30));

insert into write_hot_2(z_name,z_info) values('abc','def');

3. Observations

3.1 Downstream meter building

 show create table write_hot_3;
 CREATE TABLE `write_hot_3` (
  `id` bigint(20) NOT NULL,
  `z_name` varchar(20) DEFAULT NULL,
  `z_info` varchar(30) DEFAULT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

show create table write_hot_2;
 CREATE TABLE `write_hot_2` (
  `id` bigint(20) NOT NULL,
  `z_name` varchar(20) DEFAULT NULL,
  `z_info` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb

select * from write_hot_2;

3.2 Observe the binary condition

mysqlbinlog --base64-output=decode-rows -vv mysql-bin.000003
#  It can be found that the contents recorded in the binary system are annotated with specific comments , Explain if there is dm When syncing ,, The downstream tidb Clusters can also be created to contain SHARD_ROW_ID_BITS Table of features 
SET @@session.collation_database=DEFAULT/*!*/;
create table write_hot_3 (id bigint(20) not null, z_name varchar(20), z_info varchar(30),unique key(id)) /* 90000 SHARD_ROW_ID_BITS = 4
 PRE_SPLIT_REGIONS=3 */
/*!*/;

# at 523
#220527 10:29:16 server id 1 end_log_pos 732 CRC32 0x0564e224 Query thread_id=43 exec_time=0 error_code=0
SET TIMESTAMP=1653618556/*!*/;
create table write_hot_2(id bigint(20) not null /*T![auto_rand] auto_random */ primary key,z_name varchar(20),z_info varchar(30))
/*!*/;

# at 928
#220527 10:34:43 server id 1 end_log_pos 980 CRC32 0x3c2cef4c Write_rows: table id 121 flags: STMT_END_F
### INSERT INTO `test_db`.`write_hot_2`
### SET
### @1=4035225266123964417 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='abc' /* VARSTRING(80) meta=80 nullable=1 is_null=0 */
### @3='def' /* VARSTRING(120) meta=120 nullable=1 is_null=0 */

3、 ... and 、 Verified properties

Functions that can be synchronized normally and retain features in the binary

  1. SHARD_ROW_ID_BITS
  2. auto_random
  3. auto_random Implicit insertion of

Follow up experiments are continuously updated

原网站

版权声明
本文为[On the way to data communication]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111719373884.html