[ 
https://issues.apache.org/jira/browse/IGNITE-2554?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15132716#comment-15132716
 ] 

Artem Shutak commented on IGNITE-2554:
--------------------------------------

Investigation results.

Possible fixes:
# A simple fix. We can always set {{nodesCnt}} to 1 at {{mapKeysToNodes}} for 
local cache. It should fix the issue.
# Ignite does not store an affinity assignment history for local cache and 
always operate with {{AffinityTopologyVersion(1)}}. At the test above, an 
information about dynamically started "myCache" is available only for 
{{AffinityTopologyVersion(1, 1)}}, but Ignite does not store it. A good fix for 
the issue (and Ignite) is:
#* There is no need to store all history for local cache. So, we need just 
update the head topology version (see GridAffinityAssignmentCache.head field)
#* We must return right topology version at all project. See, for example, 
{{GridCacheAffinityManager}} and the following code
{code}
        if (cctx.isLocal())
            topVer = new AffinityTopologyVersion(1);
{code}

> Affinity.mapKeyToNode() method throw "ArithmeticException: / by zero" for 
> LOCAL dinamically started cache
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-2554
>                 URL: https://issues.apache.org/jira/browse/IGNITE-2554
>             Project: Ignite
>          Issue Type: Bug
>            Reporter: Artem Shutak
>            Priority: Minor
>
> Affinity.mapKeyToNode() method throw "ArithmeticException: / by zero" for 
> LOCAL cache.
> The following code 
> {code}
>     public static void main(String[] args) {
>         try (Ignite ignite = Ignition.start(new IgniteConfiguration())) {
>             CacheConfiguration cc = new CacheConfiguration();
>             cc.setCacheMode(LOCAL);
>             cc.setName("myCache");
>             ignite.getOrCreateCache(cc);
>             ignite.affinity("myCache").mapKeyToNode("myKey");
>         }
>     }
> {code}
> Produce the following exception.
> {noformat}
> Exception in thread "main" java.lang.ArithmeticException: / by zero
>       at 
> org.apache.ignite.internal.processors.cache.affinity.GridCacheAffinityImpl.mapKeysToNodes(GridCacheAffinityImpl.java:210)
>       at 
> org.apache.ignite.internal.processors.cache.affinity.GridCacheAffinityImpl.mapKeyToNode(GridCacheAffinityImpl.java:187)
>       at main
> {noformat}
> The issue is {{cctx.discovery().cacheAffinityNodes(cctx.name(), topVer)}} 
> returns empty nodes collection.
> If cache started on node start then there is no exception.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to