Skip to content

Commit

Permalink
Attempt to fix awaitPartitionMapExchange: wait for last exchange comp…
Browse files Browse the repository at this point in the history
…letion to avoid races with cache destroy.
  • Loading branch information
sboikov committed Apr 19, 2017
1 parent 36e7e19 commit d383484
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,27 @@ protected void awaitPartitionMapExchange(

Set<String> names = new HashSet<>();

Ignite crd = null;

for (Ignite g : G.allGrids()) {
ClusterNode node = g.cluster().localNode();

if (crd == null || node.order() < crd.cluster().localNode().order()) {
crd = g;

if (node.order() == 1)
break;
}
}

if (crd == null)
return;

AffinityTopologyVersion waitTopVer = ((IgniteKernal)crd).context().discovery().topologyVersionEx();

if (waitTopVer.topologyVersion() <= 0)
waitTopVer = new AffinityTopologyVersion(1, 0);

for (Ignite g : G.allGrids()) {
if (nodes != null && !nodes.contains(g.cluster().localNode()))
continue;
Expand All @@ -560,6 +581,19 @@ protected void awaitPartitionMapExchange(
else
startTime = g0.context().discovery().gridStartTime();

IgniteInternalFuture<?> exchFut =
g0.context().cache().context().exchange().affinityReadyFuture(waitTopVer);

if (exchFut != null && !exchFut.isDone()) {
try {
exchFut.get(timeout);
}
catch (IgniteCheckedException e) {
log.error("Failed to wait for exchange [topVer=" + waitTopVer +
", node=" + g0.name() + ']', e);
}
}

for (IgniteCacheProxy<?, ?> c : g0.context().cache().jcaches()) {
CacheConfiguration cfg = c.context().config();

Expand Down

0 comments on commit d383484

Please sign in to comment.