Hi All,
We are using 3.7.1 Aerospike Enterprise Edition for caching and getting below explained unexpected behavior.
Requirement : our requirement is to cache a list of child entries[client configuration] against a unique parent entity.
Our approach: Earlier we were inserting all config entries one by one with unique primary key for a particular entity.
For example:
parentEntity 1:
child entity:1_1
child entity:1_2
child entity:1_3
child entity:1_4
child entity:1_5
---------------java pseudocode----------------------------------------------------------------
List<childEntity> pa;
If((pa = aerospikeOperation.query(class,index,entityId)!= null)
{
return pa; //spring data aerospike;
}
else
{
childList = service.getChilds(parentId);db query
}
for(child 1---5 :childList )
{
client put{childId}
}
return childList;
But the problem we were facing with above approach was if a single entry insertion throws write timeout exception then next time we will get incomplete list [while querying from aerospike] as all above insertions were not atomic.
To Encounter above issue we created a wrapper and then we thought of inserting a complete parentWrapperObject that contains child lis at once.
---------------java pseudocode--------------
ParentWrapper pa
if((pa = aerospikeOperation.query(entityId)!= null)
{
return pa.getList();
}
else
{
childList = service.getChilds(parentId);db query
}
ParentWrapper pa = new ParentWrapper();
pa.setChilds(childList)
client.put{pa}
return childList;
[in above approach we were assuming that it would serialize the whole list in a single bin and this operation would be atomic as the wrapper object insertion would be either successful or not]
But in above approach some child data members are getting changed to null even if the values were there when we were putting those values into Aerospike:
for example:
when inserting.
parent 1:
child 1 [name:"akash",url:"www.akash.com"] [java string]
child 2 [name:"alok",url:"www.alok.com"] [java string]
while pulling the data from Aerospike:
parent 1:
child 1 [name:"akash",url:null] [java string]
child 2 [name:"alok",url:nulll] [java string]
How is it possible??? and what is the resolution for this issue:
Thanks Akash