So I've recently encountered a bug while using Ignite that drove me crazy to figure and thought this post may help some lost soul out there so here goes:
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:
Ignite cache.containsKey returns false although keys are equal