Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-3505

BinaryObject keys can't be reused because of partition caching.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6
    • 1.7
    • None
    • None

    Description

      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");
              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)); 
          }
      

      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

      Attachments

        1. 3505.patch
          4 kB
          Denis A. Magda

        Activity

          People

            dmagda Denis A. Magda
            ascherbakov Alexey Scherbakov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: