Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql到mysql端实时同步问题,修改源表字段内容,目标表不会更新源表修改的内容,而是重新生成一条新的记录 #267

Closed
zyczw opened this issue Sep 23, 2023 · 1 comment
Labels
3.8.0 bug Something isn't working
Milestone

Comments

@zyczw
Copy link

zyczw commented Sep 23, 2023

image
image
@喜楽

source 为mysql8 ,destination为 mysql5

复现:
建表语句:

DROP TABLE IF EXISTS `dd_option_data`;
CREATE TABLE `dd_option_data`  (
  `data_key` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL COMMENT ':',
  `id` bigint NOT NULL COMMENT ':',
  `type_code` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL COMMENT '类型代码:',
  `sort_num` bigint NULL DEFAULT NULL COMMENT '顺序号:',
  `data_num` int NOT NULL COMMENT '数据编号:',
  `data_code` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT NULL COMMENT '数据代码:',
  `memo_text` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT NULL COMMENT '给开发人员看的文本:界面显示文本应从资源取得。',
  `is_active` tinyint UNSIGNED NOT NULL COMMENT '是否有效:1是,0否',
  `data_from` int NULL DEFAULT NULL COMMENT '来自哪里:10标准产品,......99用户定义。',
  `remarks` varchar(300) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT NULL COMMENT '说明',
  `other_cols` varchar(1000) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL DEFAULT NULL COMMENT '其他列值(多列)',
  `create_by` bigint NULL DEFAULT NULL COMMENT '创建人:操作员id',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `modify_by` bigint NULL DEFAULT NULL COMMENT '修改人:操作员id',
  `modify_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `is_deleted` tinyint UNSIGNED NULL DEFAULT NULL COMMENT '是否删除:1删除,0没删',
  `delete_time` datetime NULL DEFAULT NULL COMMENT '删除时间',
  `res_id` bigint NOT NULL COMMENT '资源物理主键id:根据资源ID的规范,本资源ID值与数据ID值一样',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `unique_resid`(`res_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb3 COLLATE = utf8mb3_unicode_ci ROW_FORMAT = DYNAMIC;

初始化数据:

INSERT INTO `dd_option_data` VALUES ('factory_type.bj', 511900036588699690, 'factory_type', 1, 8, 'bj', '北京', 1, 99, NULL, NULL, 506325555585548289, '2023-09-23 12:09:46', 506325555585548289, '2023-09-23 12:09:46', 0, NULL, 511900036588699690);

更新数据:

update `dd_option_data` set `memo_text` = '北京1' where `id` = 511900036588699690
@baisui1981
Copy link
Member

原因分析

sink 端执行链路

TISMysqlOutputFormat -> MysqlOutputFormat -> JdbcOutputFormat#writeMultipleRecordsInternal() -> PreparedStmtProxy.convertToExternal() -> JdbcColumnConverter.toExternal() -> PreparedStmtProxy.setLong(pos,val)

故障点

IFieldNamesAttachedStatement.java 中:

    default void setLong(int pos, Long val) throws SQLException {
        getFieldNamedPstmt().setDouble(pos, val);
    }

设置long时错误调用代理类的setDouble方法,应改为:

    default void setLong(int pos, Long val) throws SQLException {
        getFieldNamedPstmt().setLong(pos, val);
    }

@baisui1981 baisui1981 added bug Something isn't working 3.8.0 labels Oct 3, 2023
@baisui1981 baisui1981 added this to the v3.8.0 milestone Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.8.0 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants