-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
In what version(s) of Spring Integration are you seeing this issue?
6.5.2
Describe the bug
RedisLockRegistry using PUB_SUB_LOCK does not work on AWS Elasticache Valkey Serverless. Internally, Elasticache uses SPUBLISH
instead of PUBLISH
, as documented on https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/SupportedCommands.html. Check the Note in the "Pub/Sub Commands" section.
PUBLISH
is used in this
Line 667 in 3811244
private static final String UNLINK_UNLOCK_SCRIPT = """ |
PUBLISH
, this does not matter, but it does with SPUBLISH
(used in Elasticache Valkey, as described).In the script, there are three Redis operations:
redis.call('GET', KEYS[1])
redis.call('UNLINK', KEYS[1])
redis.call('PUBLISH', ARGV[2], KEYS[1])
And I, as a developer, cannot control the cluster slot cache of the third operation for each separate call of the locking operation.ARGV[2]
is theunlockChannel
(seeLine 690 in 3811244
protected boolean removeLockKeyInnerUnlink() { RedisLockRegistry
(seeLine 206 in 3811244
this.unLockChannelKey = registryKey + "-channel";
I can easily control the cluster slot cache of all other operations by including a{...}
in the cache, but I cannot do the same for theunlockChannelKey
To Reproduce
- Create a
RedisLockRegistry
with aPUB_SUB_LOCK
- Attach it to an AWS Elasticache Valkey Serverless
- Alternatively (per my reasoning, that should work) change the
PUBLISH
to anSPUBLISH
in theUNLINK_UNLOCK_SCRIPT
and attach it to any valkey/redis.
- Alternatively (per my reasoning, that should work) change the
- Run a
lockRegistry.executeLocked(..)
operation - Observe the following error:
Caused by: io.lettuce.core.RedisCommandExecutionException: ERR Script attempted to access keys that do not hash to the same slot script: b2dedc0ab01c17f9f20e3e6ddb62dcb6afbed0bd, on @user_script:3.
Expected behavior
PubSubLocks should also work on AWS
Sample
I have not yet prepared a sample, as it most likely requires an AWS Elasticache Valkey, which I cannot just provide to you.