Entry processor issue

38 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Joan Balagueró

ungelesen,
30.01.2023, 06:24:5730.01.23
an Hazelcast
Hello,

hazelcast 4.2.6.

I have a map using an entry processor. Every time an element is found on the cache we increment an integer field by calling the 'addHit()' method that calls the entry processor:

public void addHit(String key) {
  this.mapRecache.executeOnKey(key,  this::applyHitToKey);
}

// This is the entry processor
private boolean applyHitToKey(Map.Entry<String, HitInfo> entry) {
  entry.setValue(entry.getValue().addHit());
  return true;
}

The point is after increment this value, the expiration time and TTL fields are changed:

These are the values before/after executing the entry processor:

(BEFORE)
addHit :: EntryView{key=36|null|1|null|null|2023-01-21|2023-01-25|9.1|10.<null>|11.0|13.AO-B0<_>AO-B1|, value=com.ventusproxy.proxy.cache.reglas.recache.HitInfo@427d2fe, cost=1198, creationTime=1675077655000, expirationTime=1675077675000, hits=0, lastAccessTime=0, lastStoredTime=0, lastUpdateTime=1675077655000, version=0, ttl=20000, maxIdle=9223372036854775807}

(AFTER)
addHit :: EntryView{key=36|null|1|null|null|2023-01-21|2023-01-25|9.1|10.<null>|11.0|13.AO-B0<_>AO-B1|, value=com.ventusproxy.proxy.cache.reglas.recache.HitInfo@427e946, cost=1198, creationTime=1675077655000, expirationTime=9223372036854775807, hits=1, lastAccessTime=1675077660000, lastStoredTime=0, lastUpdateTime=1675077660000, version=1, ttl=9223372036854775807, maxIdle=9223372036854775807}

The consequence is that entries never expire.

Is this a bug or I'm doing something wrong?

Thanks,
Joan.


Joan Balagueró

ungelesen,
30.01.2023, 11:15:4130.01.23
an Hazelcast
I have seen this issue that seems related to this:

we have tried this:
public class AddHitEntryProcessor implements EntryProcessor<String, HitInfo, Object>, Offloadable {

 @Override  
 public Object process(Map.Entry<String, HitInfo> entry) { 
   entry.setValue(entry.getValue().addHit());
   return null;
 }

 @Override  
 public EntryProcessor<String, HitInfo, Object> getBackupProcessor() {
    return null;
 }

 @Override
 public String getExecutorName() {
   return Cluster.DEFAULT_ES_NAME;
 }
}

Implementing or not implementing the offloadable interface does not make any difference, the TTL and thus the expiration date are updated.

Any help on this? This is blocking us.

Thanks.

Vassilis Bekiaris

ungelesen,
01.02.2023, 04:44:5301.02.23
an Hazelcast
Hello Joan,

this is not a bug. Since the entry was updated by the EntryProcessor, its lastUpdateTime is updated as well.

It sounds like your use case could take advantage of ExtendedMapEntry#setValueWithoutChangingExpiryTime method which was introduced in Hazelcast 5.2, maybe worth the upgrade?

Alternatively, if you want to stay on 4.2 line, you could try using `ExtendedMapEntry#setValue` with a ttl argument: you can have your EntryProcessor implement HazelcastInstanceAware, so you get a reference to the member, get the entry view for the given key and calculate a ttl that will maintain the same (more-or-less) expiry time. As a code sample of a HazelcastInstanceAware entry processor, you can have a look at https://github.com/hazelcast/hazelcast-code-samples/blob/master/enterprise/wan-replication/simulating-max-idle/src/main/java/SingleMaxIdleSimulator.java#L20-L52.

Cheers!
Vassilis

This message contains confidential information and is intended only for the individuals named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required, please request a hard-copy version. -Hazelcast
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten