Fixed - RLiveObject value shouldn't be deleted during index update. #6133

pull/6142/head
Nikita Koksharov 6 months ago
parent b90eab9539
commit fe84aed0c1

@ -215,9 +215,9 @@ public class AccessorInterceptor {
|| commandExecutor.getServiceManager().getCfg().isClusterConfig()) {
CompletableFuture<Object> f;
if (commandExecutor instanceof CommandBatchService) {
f = liveMap.removeAsync(field.getName()).toCompletableFuture();
f = liveMap.getAsync(field.getName()).toCompletableFuture();
} else {
Object value = liveMap.remove(field.getName());
Object value = liveMap.get(field.getName());
f = CompletableFuture.completedFuture(value);
}
f.thenAccept(value -> {
@ -248,7 +248,6 @@ public class AccessorInterceptor {
"if oldArg == false then " +
"return; " +
"end;" +
"redis.call('hdel', KEYS[2], ARGV[2]); " +
"local hash = redis.call('hget', KEYS[1], oldArg); " +
"local setName = KEYS[1] .. ':' .. hash; " +
"local res = redis.call('srem', setName, ARGV[1]); " +

@ -601,7 +601,47 @@ public class RedissonLiveObjectServiceTest extends RedisDockerTest {
Conditions.and(Conditions.eq("name1", "test41"), Conditions.lt("num1", 43))));
assertThat(objects6.iterator().next().getId()).isEqualTo("4");
}
@Test
public void testIndexRemoval2() throws InterruptedException {
RLiveObjectService liveObjectService = redisson.getLiveObjectService();
TestIndexed myEntity = new TestIndexed("id");
myEntity.setName1("1");
liveObjectService.persist(myEntity);
CountDownLatch latch = new CountDownLatch(1);
Runnable setterRunnable = () -> {
while (true) {
TestIndexed liveEntity = liveObjectService.get(TestIndexed.class, "id");
liveEntity.setName1("2");
}
};
Runnable getterRunnable = () -> {
int steps = 1;
while (true) {
final TestIndexed liveEntity = liveObjectService.get(TestIndexed.class, "id");
if (liveEntity.getName1() == null) {
System.out.println("IS NULL ON STEP " + steps);
latch.countDown();
}
steps++;
}
};
try (ExecutorService pool = Executors.newFixedThreadPool(2)) {
pool.submit(setterRunnable);
pool.submit(getterRunnable);
assertThat(latch.await(5, TimeUnit.SECONDS)).isFalse();
pool.shutdownNow();
}
}
@Test
public void testFindGe() {
RLiveObjectService s = redisson.getLiveObjectService();

Loading…
Cancel
Save