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

FailureHandler executed on error in ScanQuery's IgniteBiPredicate

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.7
    • Component/s: None
    • Labels:

      Description

      This code demonstrates this behavior:

      import java.util.Collections;
      import javax.cache.Cache;
      import org.apache.ignite.Ignite;
      import org.apache.ignite.IgniteCache;
      import org.apache.ignite.Ignition;
      import org.apache.ignite.binary.BinaryObject;
      import org.apache.ignite.cache.CacheAtomicityMode;
      import org.apache.ignite.cache.CacheMode;
      import org.apache.ignite.cache.query.QueryCursor;
      import org.apache.ignite.cache.query.ScanQuery;
      import org.apache.ignite.configuration.CacheConfiguration;
      import org.apache.ignite.configuration.DataRegionConfiguration;
      import org.apache.ignite.configuration.DataStorageConfiguration;
      import org.apache.ignite.configuration.IgniteConfiguration;
      import org.apache.ignite.lang.IgniteBiPredicate;
      import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
      import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
      
      /**
       * -ea -DIGNITE_QUIET=false
       */
      public class ScanQueryIgniteBiPredicateWithError {
          private static final String CACHE_NAME = "test_cache_name";
      
          public static void main(String[] args) {
              try (Ignite igniteServer = Ignition.start(getCfg("node_server", false));
                   Ignite igniteClient = Ignition.start(getCfg("node_client", true)))
              {
                  IgniteCache<Integer, BinaryObject> cache = igniteClient.cache(CACHE_NAME);
      
                  cache.put(1, igniteClient.binary().builder("test_type").setField("field_0", "field_0_val").build());
      
                  try (QueryCursor<Cache.Entry<Integer, BinaryObject>> cursor = cache.withKeepBinary().query(new ScanQuery<>(
                      new IgniteBiPredicate<Integer, BinaryObject>() {
                          @Override public boolean apply(Integer key, BinaryObject value) {
                              throw new AssertionError(); // Error.
                              //return value.field(null) != null; // Error.
                              //return true; // Ok.
                          }
                      })))
                  {
                      for (Cache.Entry<Integer, BinaryObject> entry : cursor)
                          // Without error in IgniteBiPredicate:
                          // Key = 1, Val = test_type [idHash=2024711353, hash=394028655, field_0=val_0]
                          System.out.printf("Key = %s, Val = %s%n", entry.getKey(), entry.getValue());
                  }
              }
          }
      
          /**
           * @param instanceName Ignite instance name.
           * @param clientMode Client mode.
           * @return Ignite configuration.
           */
          private static IgniteConfiguration getCfg(String instanceName, boolean clientMode) {
              TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
              ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
      
              TcpDiscoverySpi tcpDiscoverySpi = new TcpDiscoverySpi();
              tcpDiscoverySpi.setIpFinder(ipFinder);
      
              DataRegionConfiguration dataRegionCfg = new DataRegionConfiguration();
              dataRegionCfg.setPersistenceEnabled(true);
      
              DataStorageConfiguration dataStorageCfg = new DataStorageConfiguration();
              dataStorageCfg.setDefaultDataRegionConfiguration(dataRegionCfg);
      
              CacheConfiguration<Integer, BinaryObject> ccfg = new CacheConfiguration<Integer, BinaryObject>(CACHE_NAME)
                  .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
                  .setCacheMode(CacheMode.PARTITIONED);
      
              IgniteConfiguration cfg = new IgniteConfiguration();
              cfg.setIgniteInstanceName(instanceName);
              cfg.setDiscoverySpi(tcpDiscoverySpi);
              cfg.setDataStorageConfiguration(dataStorageCfg);
              cfg.setCacheConfiguration(ccfg);
      
              if (!clientMode)
                  cfg.setAutoActivationEnabled(true);
              else
                  cfg.setClientMode(true);
      
              return cfg;
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ivandasch Ivan Daschinskiy
                Reporter:
                dgladkikh Dmitriy Gladkikh
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m