matrixorigin / matrixone

Hyperconverged cloud-edge native database
https://docs.matrixorigin.cn/en
Apache License 2.0
1.77k stars 274 forks source link

[Bug]: mo-cdc: mo double type cdc to mysql double type is Inconsistence #19034

Open heni02 opened 5 days ago

heni02 commented 5 days ago

Is there an existing issue for the same bug?

Branch Name

main

Commit ID

326c9fb

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

同步到下游mysql double类型的数据和上游mo select出来的不一致,单独mysql试了下double类型插入数据结果是一致的

企业微信截图_b8ee0e82-69c7-4780-90f4-51b49739c5ee 企业微信截图_2785df19-4692-4959-ab49-3eb74651b545

Expected Behavior

No response

Steps to Reproduce

原始文件很大,写个以下简单的case看下能否复现,不行的话再联系我要原始表数据
1.上下游数据准备
mo:
create table testa(a double);
insert into testa values(81537680);
mysql:
create table testa(a double);

2.创建同步任务
3.查看下游mysql数据

Additional information

No response

heni02 commented 2 days ago

float type同步数据也是不一致 上游mo数据:(col9是float类型) mysql> select id,col9 from table_with_pk_for_load_100M where id in (30498822,30498823,30498824,30498825,30498826,30498828,30498830,30498831); +----------+------------+ | id | col9 | +----------+------------+ | 30498822 | -46958492 | | 30498823 | -11977473 | | 30498824 | -95005180 | | 30498825 | -79523920 | | 30498826 | -5466775.5 | | 30498828 | -8070154.5 | | 30498830 | -94828510 | | 30498831 | -58721676 | +----------+------------+ 8 rows in set (0.01 sec)

下游mysql数据: mysql> select id,col9 from table_with_pk_for_load_100M where id in (30498822,30498823,30498824,30498825,30498826,30498828,30498830,30498831); +----------+-----------+ | id | col9 | +----------+-----------+ | 30498822 | -46958500 | | 30498823 | -11977500 | | 30498824 | -95005200 | | 30498825 | -79523900 | | 30498826 | -5466780 | | 30498828 | -8070150 | | 30498830 | -94828500 | | 30498831 | -58721700 | +----------+-----------+ 8 rows in set (0.01 sec)

mysql table_with_pk_for_load_100M ddl: CREATE TABLE table_with_pk_for_load_100M ( id bigint NOT NULL, col1 tinyint DEFAULT NULL, col2 smallint DEFAULT NULL, col3 int DEFAULT NULL, col4 bigint DEFAULT NULL, col5 tinyint unsigned DEFAULT NULL, col6 smallint unsigned DEFAULT NULL, col7 int unsigned DEFAULT NULL, col8 bigint unsigned DEFAULT NULL, col9 float DEFAULT NULL, col10 double DEFAULT NULL, col11 varchar(255) DEFAULT NULL, col12 date DEFAULT NULL, col13 datetime DEFAULT NULL, col14 timestamp NULL DEFAULT NULL, col15 tinyint(1) DEFAULT NULL, col16 decimal(16,6) DEFAULT NULL, col17 text, col18 json DEFAULT NULL, col19 blob, col20 binary(255) DEFAULT NULL, col21 varbinary(255) DEFAULT NULL, col22 text, col23 text, col24 text, col25 text, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

ck89119 commented 1 day ago

直接往mysql插入数据,发现也会丢失后面几位精度

mysql> create table t3 (id bigint NOT NULL, col9 float DEFAULT NULL, PRIMARY KEY (id));
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t3 values
    ->     (30498822, -46958492),
    ->     (30498823, -11977473),
    ->     (30498824, -95005180),
    ->     (30498825, -79523920),
    ->     (30498826, -5466775.5),
    ->     (30498828, -8070154.5),
    ->     (30498830, -94828510),
    ->     (30498831, -58721676);
Query OK, 8 rows affected (0.02 sec)
Records: 8  Duplicates: 0  Warnings: 0

mysql> select * from t3;
+----------+-----------+
| id       | col9      |
+----------+-----------+
| 30498822 | -46958500 |
| 30498823 | -11977500 |
| 30498824 | -95005200 |
| 30498825 | -79523900 |
| 30498826 |  -5466780 |
| 30498828 |  -8070150 |
| 30498830 | -94828500 |
| 30498831 | -58721700 |
+----------+-----------+
8 rows in set (0.00 sec)
ck89119 commented 1 day ago

issue中提到的double类型的case不能复现

ck89119 commented 1 day ago

经沟通验证,issue截图中数据不一致的列是float类型不是double类型,原因是精度不够;double类型是没问题的