IGNITE-2796 NPE during rebalancing
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 273b603..0cf974f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -841,6 +841,8 @@
*/
private void appendPartitions(UUID nodeId, Collection<Integer> parts) {
synchronized (this) {
+ assert parts != null : "Partitions are null [cache=" + cctx.name() + ", fromNode=" + nodeId + "]";
+
remaining.put(nodeId, new T2<>(U.currentTimeMillis(), parts));
}
}
@@ -972,22 +974,25 @@
preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
exchFut.discoveryEvent());
- Collection<Integer> parts = remaining.get(nodeId).get2();
+ T2<Long, Collection<Integer>> t = remaining.get(nodeId);
- if (parts != null) {
- boolean rmvd = parts.remove(p);
+ assert t != null : "Remaining not found [cache=" + cctx.name() + ", fromNode=" + nodeId +
+ ", part=" + p + "]";
- assert rmvd : "Partition already done [cache=" + cctx.name() + ", fromNode=" + nodeId +
- ", part=" + p + ", left=" + parts + "]";
+ Collection<Integer> parts = t.get2();
- if (parts.isEmpty()) {
- U.log(log, "Completed " + ((remaining.size() == 1 ? "(final) " : "") +
- "rebalancing [cache=" + cctx.name() +
- ", fromNode=" + nodeId + ", topology=" + topologyVersion() +
- ", time=" + (U.currentTimeMillis() - remaining.get(nodeId).get1()) + " ms]"));
+ boolean rmvd = parts.remove(p);
- remaining.remove(nodeId);
- }
+ assert rmvd : "Partition already done [cache=" + cctx.name() + ", fromNode=" + nodeId +
+ ", part=" + p + ", left=" + parts + "]";
+
+ if (parts.isEmpty()) {
+ U.log(log, "Completed " + ((remaining.size() == 1 ? "(final) " : "") +
+ "rebalancing [cache=" + cctx.name() +
+ ", fromNode=" + nodeId + ", topology=" + topologyVersion() +
+ ", time=" + (U.currentTimeMillis() - t.get1()) + " ms]"));
+
+ remaining.remove(nodeId);
}
checkIsDone();