redis / redis

Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.

Home Page:http://redis.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistency in Redisson's RLiveObjectService.find() Method: Retrieving Outdated Data Despite Updates

karthik2020mind opened this issue · comments

Issue Description:
The RLiveObjectService.find() method in Redisson is returning objects with outdated status values, despite the status being updated in the Redis cache. The search should be conducted based on the latest value of the status field, but it continues to retrieve objects with older status values, leading to inconsistency in the retrieved data.

In the given code snippet, an instance of RLiveObjectService is obtained from the Redisson client using the getLiveObjectService() method:

RLiveObjectService service = redisson.getLiveObjectService();

This service is used to interact with live objects stored in Redis, allowing for seamless integration between Java objects and Redis data structures.

Next, the find() method of the RLiveObjectService is invoked to search for instances of the MyCustomObject class based on a specified condition. The condition is constructed using the Conditions class to ensure that only objects with a status field equal to "processing" are retrieved:

List<MyCustomObject> results = service.find(MyCustomObject.class, Conditions.and(Conditions.eq("status","processing")));

The expectation is that the find() method should return a list of MyCustomObject instances where the status field is "processing". However, the observed behavior contradicts this expectation, as the returned list contains MyCustomObject instances with statuses other than "processing".

Upon further investigation, it is discovered that although the initial status of the MyCustomObject instances stored in Redis was "processing", some of them were later updated to a different status, such as "completed". Despite this update, the find() method continues to return objects with the outdated "processing" status.

The expectation is that the search should be conducted based on the latest value of the status field in the Redis cache. However, it is unclear why the find() method is returning objects with older status values, even after they have been updated.

This discrepancy raises concerns about the consistency and accuracy of the search functionality provided by the RLiveObjectService, as it appears to be retrieving outdated data from the Redis cache.

expected result: [{"field1":"val",.......,"status":"processing"},{"field1":"val",.......,"status":"processing"},{"field1":"val",.......,"status":"processing"}]
actual result : [{"field1":"val",.......,"status":"completed"},{"field1":"val",.......,"status":"completed"},{"field1":"val",.......,"status":"processing"}]

RedissonClient Configuration

@Bean(destroyMethod = "shutdown")
   public RedissonClient redisson() throws IOException {
      
       Config config = new Config();
       config.useReplicatedServers().addNodeAddress("rediscluster-node-endpoint");
       
       config.setMinCleanUpDelay(5); 
       config.setMaxCleanUpDelay(60); 
       config.setCleanUpKeysAmount(1000); 

       return Redisson.create(config);
   }

MyCustomObject.class

@Data
@REntity
public class MyCustomObject {
    private String field1;
    private String field2;
    private String field3;
    @RIndex
    private String field4;
    @RIndex
    private String status;
    @RId
    private String id;
}

Code Snippet used to store and update

 RLiveObjectService service = redisson.getLiveObjectService();
 myCustomObject = service.merge(myCustomObject);
 service.asRMap(myCustomObject).expire(config.getTtl(), TimeUnit.DAYS);

Redis Engine version : 7.1.0
redisson version : 3.29.0

Hi @sundb created ticket redisson/redisson#5827 , Thank you