Skip to content

Commit

Permalink
删除操作计算hash值的情况没有考虑,导致删除时的分区和插入时的分区不一致 (#1848)
Browse files Browse the repository at this point in the history
  • Loading branch information
yabola authored and agapple committed May 27, 2019
1 parent d0a83aa commit 37fc248
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,25 @@ public static Message[] messagePartition(Message message, Integer partitionsNum,
}
}
} else {
for (CanalEntry.Column column : rowData.getAfterColumnsList()) {
if (checkPkNamesHasContain(hashMode.pkNames, column.getName())) {
hashCode = hashCode ^ column.getValue().hashCode();
try {
CanalEntry.EventType eventType = RowChange.parseFrom(entry.getStoreValue()).getEventType();
if(eventType == CanalEntry.EventType.DELETE){
for (CanalEntry.Column column : rowData.getBeforeColumnsList()) {
if (checkPkNamesHasContain(hashMode.pkNames, column.getName())) {
hashCode = hashCode ^ column.getValue().hashCode();
}
}
}
else {
for (CanalEntry.Column column : rowData.getAfterColumnsList()) {
if (checkPkNamesHasContain(hashMode.pkNames, column.getName())) {
hashCode = hashCode ^ column.getValue().hashCode();
}
}
}
}
catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}

Expand Down

0 comments on commit 37fc248

Please sign in to comment.