Our objective is to use LettuceConfiguration for Redis Sentinel server to obtain the Redis lock and for caching @Cachable.
We are having the following problem.
: Failed to complete request: org.springframework.dao.CannotAcquireLockException: Failed to lock mutex at DEFAULT_LOCK_REGISTRY:userid; nested exception is org.springframework.data.redis. RedisSystemException: Error in execution; nested exception is io.lettuce.core. RedisCommandExecutionException: ERR Error running script (call to f_8426
c8df41c64d8177dce3ecbbe9146ef3759cd2): @user_script:6: @user_script: 6: -READONLY You can't write against a read only slave.
Configuration looks like below:
/**
* Lettuce
*/
@Bean("redisslaveconnection")
public RedisConnectionFactory lettuceConnectionFactory() {
RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration()
.master("mymaster")
.sentinel("127.0.0.1", 16380);
sentinelConfig.setPassword("xxxxx");
LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
.commandTimeout(redisCommandTimeout)
.readFrom(ReadFrom.REPLICA_PREFERRED)
.clientOptions(clusterClientOptions())
.build();
return new LettuceConnectionFactory(sentinelConfig, clientConfig);
}
@Bean
public RedisCacheManager cacheManager() {
return RedisCacheManager.builder(this.lettuceConnectionFactory()).cacheDefaults(this.cacheConfiguration())
.build();
}
@Bean
public RedisLockRegistry lockRegistry(RedisConnectionFactory cf) {
return new RedisLockRegistry(cf, "Lock_Registery_Name", 120000);
}
We have a RedisScript to get the lock inside the RedisLockRegistry.
Please let me know whether Lettuce will accept this kind of script or if there are any other options I can use with Read REPLICA PREFERRED settings. Do you think it would be a good idea to create two beans with the properties MASTER PREFERRED and REPLICA PREFERRED in order to gain the lock MASTER PREFERRED bean and for @CacheManager REPLICA PREFERRED bean?
Our objective is to use LettuceConfiguration for Redis Sentinel server to obtain the Redis lock and for caching @Cachable. We are having the following problem.
Configuration looks like below:
We have a RedisScript to get the lock inside the RedisLockRegistry.
Please let me know whether Lettuce will accept this kind of script or if there are any other options I can use with Read REPLICA PREFERRED settings. Do you think it would be a good idea to create two beans with the properties MASTER PREFERRED and REPLICA PREFERRED in order to gain the lock MASTER PREFERRED bean and for @CacheManager REPLICA PREFERRED bean?