You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Ramzinator <ra...@gmail.com> on 2017/02/10 13:57:45 UTC

Bug with using Map as a cache key in Ignite

Hi GridGain/Ignite guys,

I've recently encountered a bug while using Ignite.

The scenario is as follows:I have a class *A* that just has a
*java.util.Map* field that I am using as an ignite cache key to map to some
value.

I have 2 instances of the same service: *S1* & *S2* , each running an ignite
node.
Let's refer to the ignite nodes of the instances as nodes *N* and *M*

Both services are doing affinityCalls on ignite, so whatever instance of the
service is used, the ignite call will go to the same node.

The scenario that happens is as follows:
1. Service *S1* does an affinity call on *N* and stores in *N*'s cache a
mapping of *A* -> Value *V*
2. Service *S2* does the same affinity call and goes to *N*, However, when
trying to retrieve the value that was put in *N*'s cache by step 1, it fails
to retrieve it as if the cache doesn't contain it.

To make things clearer, consider the following pseudo code:

*S1 does the following in Step 1.*

IgniteCache igniteCache=....;

Map map1= new Map();
map1.put("some key","some value");

*A* cacheKey= new *A*(map);

igniteCache.put(keyInCache, anything);

*S2 does the following in Step 2*

IgniteCache igniteCache=....;

Map map2= new Map();
map2.put("some key", "some value");

*A* keyToRetrieve= new *A*(map2);

igniteCache.contains(keyToRetrive) --> *false*.

even though keyToRetrieve.equals(cacheKey) is *true*.

and the cache does indeed contain cacheKey.

The culprit of the issue as I found it to be was the use of Map as a field
in the key of type *A*.
As it seems ignite has trouble with dealing with keys that have Map members,
as also mentioned  here
<http://stackoverflow.com/questions/38145923/ignite-cache-containskey-returns-false-although-keys-are-equal> 
:

What annoys me is that it does not state or prohibit the use of a Map in
cache key anywhere.
So I leave it you whether to make it possible or clearly prohibit it.

Thanks,
Rami Hammoud



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Bug-with-using-Map-as-a-cache-key-in-Ignite-tp10549.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Bug with using Map as a cache key in Ignite

Posted by vkulichenko <va...@gmail.com>.
Responded on StackOverflow:
http://stackoverflow.com/questions/42161278/bug-using-map-as-a-cache-key-in-ignite

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Bug-with-using-Map-as-a-cache-key-in-Ignite-tp10549p10554.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.