Merge pull request #3688 from UzimakiNaruto/master

fix ClusterConnectionManager#checkSlotsMigration map slot-partitions bug after re-sharding slots
pull/3696/head
Nikita Koksharov 4 years ago committed by GitHub
commit 4acdf567d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -658,14 +658,23 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
}
private void checkSlotsMigration(Collection<ClusterPartition> newPartitions) {
Set<ClusterPartition> clusterLastPartitions = getLastPartitions();
// https://github.com/redisson/redisson/issues/3635
Map<String, MasterSlaveEntry> nodeEntry = new HashMap<>();
clusterLastPartitions.forEach(partition -> {
nodeEntry.put(partition.getNodeId(), getEntry(partition.slots().nextSetBit(0)));
});
Set<Integer> changedSlots = new HashSet<>();
for (ClusterPartition currentPartition : getLastPartitions()) {
for (ClusterPartition currentPartition : clusterLastPartitions) {
String nodeId = currentPartition.getNodeId();
for (ClusterPartition newPartition : newPartitions) {
if (!Objects.equals(currentPartition.getNodeId(), newPartition.getNodeId())) {
if (!Objects.equals(nodeId, newPartition.getNodeId())) {
continue;
}
MasterSlaveEntry entry = getEntry(currentPartition.slots().nextSetBit(0));
MasterSlaveEntry entry = nodeEntry.get(nodeId);
BitSet addedSlots = newPartition.copySlots();
addedSlots.andNot(currentPartition.slots());
currentPartition.addSlots(addedSlots);

Loading…
Cancel
Save