cancel
Showing results for 
Search instead for 
Did you mean: 

CROSSSLOT Keys issue with Redis 7

CROSSSLOT Keys issue with Redis 7

Hi,

 I have upgraded the Magento version 2.4.3 to 2.4.7-3. After upgraded the website, I am getting below error:

CROSSSLOT Keys in request don't hash to the same slot (context='', command='sinter', original-slot='6566', wrong-slot='701', first-key='zc:ti:011_FPC',  violating-key='zc:ti:011_MAGE')

 My website is hosted on the Azure and I was used the Redis 6 with Magento old version 2.4.3. 

Now with upgraded version 2.4.7-3, I am using the Azure Redis 7 enterprise for managing the cache and session and getting the above error message.

 So can anyone please help me to fix this issue?

 Thanks

4 REPLIES 4

Re: CROSSSLOT Keys issue with Redis 7

When working with Redis 7 in a clustered environment, a CROSSSLOT Keys error occurs when a command attempts to access multiple keys that belong to different hash slots. Redis Cluster partitions data across multiple nodes espaço invisível 2025 using a hashing mechanism, and each key is assigned to a specific slot. Commands that involve multiple keys, such as transactions (MULTI/EXEC), MSET, or MGET, must operate on keys that reside in the same slot.

Re: CROSSSLOT Keys issue with Redis 7

This error occurs because Redis Cluster enforces hash slot consistency, and Magento is trying to perform operations on keys mapped to different slots. Since you upgraded from Redis 6 to Redis 7 in cluster mode, ensure that Magento’s Redis configuration is set correctly. Checking your env.php file and enabling Creative Operations Optimization can help maintain efficient cache management and prevent key conflicts. You may also need to enable consistent hashing to keep related keys in the same slot. Try flushing the Redis cache and verify that session storage is correctly namespaced. If the issue persists, consider using a single-node Redis setup instead of a cluster.

Re: CROSSSLOT Keys issue with Redis 7

To ensure that your Redis setup is configured properly after upgrading to Redis 7 and resolving the CROSSSLOT error, you'll need to carefully review the key distribution strategy. Redis operates using hash slots for cluster operations, and the error you're encountering happens when keys aren't in the same slot. One potential solution is adjusting the key distribution to ensure related keys are hashed into the same slot. Additionally, checking Magento's compatibility with Redis 7 can help ensure smoother integration, avoiding issues with cache and session management. If you're looking for something new and flavorful to enjoy while troubleshooting, you can also check out Geek Bar Flavors, which offers a range of delicious options to enhance your experience while you work on resolving the issue.

Re: CROSSSLOT Keys issue with Redis 7


@SThakurmed07d4 wrote:

Hi,

 I have upgraded the Magento version 2.4.3 to 2.4.7-3. After upgraded the website, I am getting below error:

CROSSSLOT Keys in request don't hash to the same slot (context='', command='sinter', original-slot='6566', wrong-slot='701', first-key='zc:ti:011_FPC',  violating-key='zc:ti:011_MAGE')

 My website is hosted on the Azure and I was used the Redis 6 with Magento old version 2.4.3. 

Now with upgraded version 2.4.7-3, I am using the Azure Redis 7 enterprise for managing the cache and session and getting the above error message.

 So can anyone please help me to fix this issue?

 Thanks


The CROSSLOT error occurs because, in Redis cluster mode, commands involving multiple keys (like SINTER) only work if all keys are in the same hash slot. In your case, the keys zc:ti:011_FPC and zc:ti:{011}_FPC zc:ti:{011}_MAGE are hashed into different slots, which causes the error.

Sometimes, this can also happen if there's an invisible space (espaço invisível) or hidden character in the key names, making them hash differently even if they look similar.

Possible solutions:

  1. Use hash tags in your Redis keys: To force related keys into the same hash slot, wrap a common part of the key in curly braces {}:

    zc:ti:{011}_FPC zc:ti:{011}_MAGE

    Redis will only hash the part inside the braces (011), ensuring both keys go into the same slot.

  2. Check if Redis is running in cluster mode: This error only happens in cluster mode. If you don’t require horizontal scaling with clustering, consider switching to standalone mode, which doesn’t have this slot limitation.

  3. Magento compatibility: While Magento 2.4.7-p3 supports Redis 7, it does not fully support Redis in cluster mode for all operations, especially when using cache or session storage. It's recommended to use Redis in standalone mode with Magento unless you’re handling key hashing manually.

Use hash tags in key names, double-check for any hidden characters or invisible spaces (espaço invisível), and consider disabling Redis cluster mode for Magento to avoid these issues.

Let me know if you need help adjusting your Magento config!