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

Roman Guseinov commented on IGNITE-9878:
----------------------------------------

[~vkulichenko], thanks for your comment. 

I believe it should work like `IgniteCache<K, V> 
getOrCreateCache(CacheConfiguration<K, V> cacheCfg)`. You can call this method 
with the same cacheCfg multiple times without any errors.

If you try to do the same with `IgniteCache<K, V> 
getOrCreateCache(CacheConfiguration<K, V> cacheCfg,  NearCacheConfiguration<K, 
V> nearCfg)` the first call will be successful, but the second one will fail. 
Does it look correct to you? Why Ignite should throw an exception instead of 
returning the same results (like for the first call)?

> Failed to start near cache after second call of getOrCreateCache
> ----------------------------------------------------------------
>
>                 Key: IGNITE-9878
>                 URL: https://issues.apache.org/jira/browse/IGNITE-9878
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>    Affects Versions: 2.6
>            Reporter: Roman Guseinov
>            Assignee: Roman Guseinov
>            Priority: Major
>         Attachments: NearCacheIssueReproducer.java, NearCacheTest.java
>
>
> Repeated call of `Ignite.getOrCreateCache(CacheConfiguration<K, V> cacheCfg, 
> NearCacheConfiguration<K, V> nearCfg)` lead the following exception:
> {code:java}
> javax.cache.CacheException: class org.apache.ignite.IgniteCheckedException: 
> Failed to start near cache (local node is an affinity node for cache): 
> ignite-test-near-rep
>       at 
> org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1305)
>       at 
> org.apache.ignite.internal.IgniteKernal.getOrCreateCache(IgniteKernal.java:2995)
>       at 
> org.apache.ignite.reproducers.cache.NearCacheIssueReproducer.testRepeatedGetOrCreateCache(NearCacheIssueReproducer.java:24)
> Caused by: class org.apache.ignite.IgniteCheckedException: Failed to start 
> near cache (local node is an affinity node for cache): ignite-test-near-rep
>       at 
> org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareCacheChangeRequest(GridCacheProcessor.java:5235)
>       at 
> org.apache.ignite.internal.processors.cache.GridCacheProcessor.dynamicStartCache(GridCacheProcessor.java:3621)
>       at 
> org.apache.ignite.internal.processors.cache.GridCacheProcessor.dynamicStartCache(GridCacheProcessor.java:3560)
>       at 
> org.apache.ignite.internal.IgniteKernal.getOrCreateCache(IgniteKernal.java:2983)
>       ... 23 more
> {code}
> Also, if a cache is specified in the IgniteConfiguration, 
> `Ignite#getOrCreateNearCache` will fail with the following exception:
> {code:java}
> javax.cache.CacheException: class org.apache.ignite.IgniteCheckedException: 
> Failed to start near cache (a cache with the same name without near cache is 
> already started)
>       at 
> org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1305)
>       at 
> org.apache.ignite.internal.IgniteKernal.getOrCreateNearCache(IgniteKernal.java:3072)
>       at 
> org.apache.ignite.reproducers.cache.NearCacheIssueReproducer.testGetOrCreateNearCache(NearCacheIssueReproducer.java:32)
> Caused by: class org.apache.ignite.IgniteCheckedException: Failed to start 
> near cache (a cache with the same name without near cache is already started)
>       at 
> org.apache.ignite.internal.IgniteKernal.checkNearCacheStarted(IgniteKernal.java:3085)
>       at 
> org.apache.ignite.internal.IgniteKernal.getOrCreateNearCache(IgniteKernal.java:3067)
>       ... 23 more
> {code}
> The test is attached   [^NearCacheIssueReproducer.java]. The workaround is to 
> put near cache config into cache configuration 
> `CacheConfiguration.setNearConfiguration`.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to