fun_with_flags icon indicating copy to clipboard operation
fun_with_flags copied to clipboard

Use with AWS Elasticache Reds in cluster mode

Open Rodeoclash opened this issue 5 months ago • 1 comments

We're getting an odd error when attempting to set flags with our Redis which is hosted on Elasticache using the aws_elasticache_serverless_cache mode.

iex(super_api@ip-10-0-32-236)1> FunWithFlags.UI.Utils.create_flag_with_name("use_aws_for_phone_verification")
{:error,
 "Redis Error: one of the commands failed: [\"OK\", \"QUEUED\", \"QUEUED\", %Redix.Error{message: \"CROSSSLOT Keys in request don't hash to the same slot\"}]"}

This appears to be related to the code here:

https://github.com/tompave/fun_with_flags/blob/master/lib/fun_with_flags/store/persistent/redis.ex#L48-L53

Any thoughts on how to approach a fix? 🙂

Rodeoclash avatar Jul 11 '25 03:07 Rodeoclash

Hey there, thank you for using the package and for reporting the problem.

I'm not familiar with aws_elasticache_serverless_cache mode, but it looks like the ElastiCache Redis interface to which you're connected is automatically distributing keys to different shards in the cluster (based on a hash of the key), and this is failing because the commands are being sent in a transaction.

I'm not sure I have an easy fix for that, especially because I believe that the clustering/sharding details are opaque and managed by ElastiCache.

I'd suggest to not rely on clustered ElastiCache, then.

tompave avatar Jul 11 '25 21:07 tompave