ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexei Scherbakov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IGNITE-3505) BinaryObject keys can't be reused because of partition caching.
Date Tue, 19 Jul 2016 10:52:20 GMT
Alexei Scherbakov created IGNITE-3505:

             Summary: 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

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:

if (key instanceof KeyCacheObject && ((KeyCacheObject)key).partition() != -1)
            return ((KeyCacheObject)key).partition();

The issue can be reproduced with the following 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");

        IgniteCache<BinaryObject, BinaryObject> cache1 =

        CacheConfiguration<BinaryObject, BinaryObject> cfg2 = new
            CacheConfiguration<>("Cache 2");

        IgniteCache<BinaryObject, BinaryObject> cache2 =

        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

This message was sent by Atlassian JIRA

View raw message