mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
删除操作计算hash值的情况没有考虑,导致删除时的分区和插入时的分区不一致 (#1848)
This commit is contained in:
@@ -230,12 +230,27 @@ public class MQMessageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
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()) {
|
for (CanalEntry.Column column : rowData.getAfterColumnsList()) {
|
||||||
if (checkPkNamesHasContain(hashMode.pkNames, column.getName())) {
|
if (checkPkNamesHasContain(hashMode.pkNames, column.getName())) {
|
||||||
hashCode = hashCode ^ column.getValue().hashCode();
|
hashCode = hashCode ^ column.getValue().hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (InvalidProtocolBufferException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int pkHash = Math.abs(hashCode) % partitionsNum;
|
int pkHash = Math.abs(hashCode) % partitionsNum;
|
||||||
pkHash = Math.abs(pkHash);
|
pkHash = Math.abs(pkHash);
|
||||||
|
|||||||
Reference in New Issue
Block a user