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

1.1.3 message partition 导致数据重复 #1551

Closed
oscar-zyh opened this issue Feb 28, 2019 · 2 comments
Closed

1.1.3 message partition 导致数据重复 #1551

oscar-zyh opened this issue Feb 28, 2019 · 2 comments
Milestone

Comments

@oscar-zyh
Copy link

oscar-zyh commented Feb 28, 2019

environment

  • canal version: 1.1.3-alpha2
  • mysql version: 5.7.22

Issue Description

1.1.3中新增的对 Message 的 partition 逻辑,如果一个 Canal Entry 包含 n 个 rowData,则 Canal Entry 在partition 之后会重复 n 倍

// canal/server/src/main/java/com/alibaba/otter/canal/common/MQMessageUtils.java
for (CanalEntry.RowData rowData : rowChange.getRowDatasList()) {
    int hashCode = table.hashCode();
    if (hashMode.autoPkHash) {
        // isEmpty use default pkNames
        for (CanalEntry.Column column : rowData.getAfterColumnsList()) {
            if (column.getIsKey()) {
                hashCode = hashCode ^ column.getValue().hashCode();
            }
        }
    } else if (!hashMode.tableHash) {
        for (CanalEntry.Column column : rowData.getAfterColumnsList()) {
            if (checkPkNamesHasContain(hashMode.pkNames, column.getName())) {
                hashCode = hashCode ^ column.getValue().hashCode();
            }
        }
    }

    int pkHash = Math.abs(hashCode) % partitionsNum;
    pkHash = Math.abs(pkHash);
    partitionEntries[pkHash].add(entry);
}

Steps to reproduce

对于一个n行的表 t
delete from t;
Canal Entry 的 rowData 会产生多行

Expected behaviour

partition 后产生一个 Entry

Actual behaviour

partition 后产生n个 Entry

@agapple
Copy link
Member

agapple commented Mar 5, 2019

建议先改为flatMessage模式

@agapple
Copy link
Member

agapple commented Mar 21, 2019

1.1.3 alpha-3 已经修复

@agapple agapple closed this as completed Mar 21, 2019
@agapple agapple added this to the v1.1.3 milestone Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants