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

Alexey Goncharuk commented on IGNITE-3505:
------------------------------------------

Denis,

Looks good to me.

> BinaryObject keys can't be reused because of partition caching.
> ---------------------------------------------------------------
>
>                 Key: IGNITE-3505
>                 URL: https://issues.apache.org/jira/browse/IGNITE-3505
>             Project: Ignite
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Alexei Scherbakov
>            Assignee: Denis Magda
>             Fix For: 1.7
>
>         Attachments: 3505.patch
>
>
> BinaryObject can't be reused as key between caches because it's
> actual implementation BinaryObjectImpl implements KeyCacheObject and
> due to the fact caches partition, which is not recalculated later.
> See 
> org.apache.ignite.internal.processors.cache.GridCacheAffinityManager.partition:
> {code}
> if (key instanceof KeyCacheObject && ((KeyCacheObject)key).partition() != -1)
>             return ((KeyCacheObject)key).partition();
> {code}
> The issue can be reproduced with the following code:
> {code}
> public static void main(String[] args) throws IgniteException {
>         IgniteConfiguration cfg = new IgniteConfiguration();
>         cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(new 
> TcpDiscoveryVmIpFinder(true)));
>         Ignite ignite = Ignition.start(cfg);
>         CacheConfiguration<BinaryObject, BinaryObject> cfg1 = new
>             CacheConfiguration<>("Cache 1");
>         cfg1.setCacheMode(CacheMode.PARTITIONED);
>         cfg1.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>         IgniteCache<BinaryObject, BinaryObject> cache1 =
>             ignite.getOrCreateCache(cfg1).withKeepBinary();
>         CacheConfiguration<BinaryObject, BinaryObject> cfg2 = new
>             CacheConfiguration<>("Cache 2");
>         cfg2.setCacheMode(CacheMode.REPLICATED);
>         
> cfg2.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
>         IgniteCache<BinaryObject, BinaryObject> cache2 =
>             ignite.getOrCreateCache(cfg2);
>         BinaryObjectBuilder keyBuilder = ignite.binary().builder("keyType")
>                 .setField("F1", "V1").hashCode("V1".hashCode());
>         BinaryObjectBuilder valBuilder = ignite.binary().builder("valueType")
>                 .setField("F2", "V2")
>                 .setField("F3", "V3");
>         BinaryObject key = keyBuilder.build();
>         BinaryObject val = valBuilder.build();
>         cache1.put(key, val);
>         cache2.put(key, val); // error
>         System.out.println(cache1.get(key)); // error
>         System.out.println(cache2.get(key)); 
>     }
> {code}
> Corresponding user list thread: 
> http://apache-ignite-users.70518.x6.nabble.com/Adding-a-binary-object-to-two-caches-fails-with-FULL-SYNC-write-mode-configured-for-the-replicated-ce-tp6343p6366.html



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

Reply via email to