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

Expiry policy is not applied to Ignite cache after serialization

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.11
    • None
    • cache
    • Docs Required, Release Notes Required

    Description

      Expiry Policy specified in Ignite cache operation context is not applied to the cache after the cache serialization/deserialization.

      Steps to Reproduce

      1. Run an Ignite server with a cache without expiry policy
      2. A client node joins the server, gets the cache proxy and applies expiry policy to the cache proxy
      3. The client executes a Compute task taking the cache proxy as a parameter on the server.
      4. The Compute task puts an entry to the cache using the cache proxy received from the client.
      5. The client sleeps for a time period longer than the TTL specified for the expiry policy
      6. The client checks if the entry that the Compute task added still exists

      Expected

      The entry does not exist since it must expire

      Actual

      The entry still exists in the cache.

      Reproducer

      public class IgniteCacheSerializationTest {
          /** Expiry Policy specified in Ignite cache operation context is enabled after the cache serialization. */
          @Test
          public void igniteCacheWithExpiryPolicySerialization() throws InterruptedException {
              var cacheName = "cache1";
              var ttl = 1000;
      
              Supplier<IgniteConfiguration> igniteCfgFactory = () ->
                  new IgniteConfiguration()
                      .setDiscoverySpi(
                          new TcpDiscoverySpi()
                              .setIpFinder(
                                  new TcpDiscoveryVmIpFinder().setAddresses(Collections.singleton("127.0.0.1:47500"))
                              )
                      )
                      .setCacheConfiguration(new CacheConfiguration<>(cacheName));
      
              try (var ignored = Ignition.start(igniteCfgFactory.get().setIgniteInstanceName("server"))) {
                  try (var ignite = Ignition.start(
                      igniteCfgFactory.get().setIgniteInstanceName("test").setClientMode(true))
                  ) {
                      // Apply a 1-second expiry policy to the cache
                      var expiryPolicy = TouchedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, ttl)).create();
      
                      var cache = ignite.<Integer, String>cache(cacheName).withExpiryPolicy(expiryPolicy);
      
                      // Run a Compute Task that serializes the cache with the 1-second expiry policy applied.
                      // The task adds a key 1 to the cache
                      ignite.compute().affinityRun(cacheName, 1, new Put1(cache));
      
                      // Sleep for a time twice longer than the TTL
                      Thread.sleep(ttl * 2);
      
                      // The key 1 must expiry by this time
                      assertFalse(cache.containsKey(1), "The entry still exists in the cache");
                  }
              }
          }
      
          private static final class Put1 implements IgniteRunnable {
              private final IgniteCache<Integer, String> cache;
      
              public Put1(IgniteCache<Integer, String> cache) {
                  this.cache = cache;
              }
      
              @Override public void run() {
                  cache.put(1, "ignored");
              }
          }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            kukushal Alexey Kukushkin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 56h
                56h
                Remaining:
                Remaining Estimate - 56h
                56h
                Logged:
                Time Spent - Not Specified
                Not Specified