You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Alexey Kukushkin (Jira)" <ji...@apache.org> on 2022/05/12 07:22:00 UTC
[jira] [Updated] (IGNITE-16135) Expiry policy is not applied to Ignite cache after serialization
[ https://issues.apache.org/jira/browse/IGNITE-16135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexey Kukushkin updated IGNITE-16135:
--------------------------------------
Remaining Estimate: 168h
Original Estimate: 168h
> Expiry policy is not applied to Ignite cache after serialization
> ----------------------------------------------------------------
>
> Key: IGNITE-16135
> URL: https://issues.apache.org/jira/browse/IGNITE-16135
> Project: Ignite
> Issue Type: Bug
> Components: cache
> Affects Versions: 2.11
> Reporter: Alexey Kukushkin
> Priority: Major
> Labels: cggg
> Original Estimate: 168h
> Remaining Estimate: 168h
>
> Expiry Policy specified in Ignite cache operation context is not applied to the cache after the cache serialization/deserialization.
> h3. Steps to Reproduce
> # Run an Ignite server with a cache without expiry policy
> # A client node joins the server, gets the cache proxy and applies expiry policy to the cache proxy
> # The client executes a Compute task taking the cache proxy as a parameter on the server.
> # The Compute task puts an entry to the cache using the cache proxy received from the client.
> # The client sleeps for a time period longer than the TTL specified for the expiry policy
> # The client checks if the entry that the Compute task added still exists
> h3. Expected
> The entry does not exist since it must expire
> h3. Actual
> The entry still exists in the cache.
> h3. Reproducer
> {code:java}
> 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");
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)