Fixing Redis cluster shard importing the wrong RDB

December 4, 2026
Author
Hieu Nguyen
Share this Post:

During your daily life managing Redis clusters, you might encounter the issue where a shard in your cluster grabs the RDB file meant for single instances or other shards during startup. So the node will have data meant for other shards. For example, when scanning the cluster for a particular key, it shows up on 2 nodes

In Redis 8.6 onward (and 8.0 for Valkey), this issue will automatically resolve by the server deleting keys that do not belong to its owned slots, and you will get the following messages in the log file:

But in older versions, the keys will not be deleted (instead, the affected slots are set to IMPORTING state), which will create operational headaches (duplicated keys still consume memory and create confusion in keyspace management). This article will list out a few ways in which you can solve the problem.

The happiest scenario: you still have the correct RDB file

If you still have the RDB file meant for the shard, solving the issue is simple. Just shut down the instance with SHUTDOWN NOSAVE, point the configs (dir, dbfilename, and/or appenddirname if you use AOF) to the correct RDB file (or copy the RDB file to the correct directory), and then start the instance again. Problem solved!

The not-so-happy scenario: the applications had written data into the shard

If you did not detect the issue right away and applications have written new data into the shard, restarting the node with the correct RDB file will no longer work. Since we now have data mismatch between the two RDBs.

What to do now?

The good news is that your application won’t get stale data held by the wrong node. Since the cluster still has the correct data about hash slot ownership, when applications read/write to keys in the affected slot, they will still get redirected to the correct owner.

So now we can reclaim the memory by deleting the errant keys

Find out which slots are affected

We can find the errant keys by listing out how many slots are affected by the wrong RDB load. Simply run redis-cli –cluster check, and we will see a warning about slots in IMPORTING state.

 

List the keys in affected slot(s)

After we get the affected slots, run CLUSTER GETKEYSINSLOT to find how many keys they have

So, in this example, slot 5871 has only one key named 884.

Delete the errant keys

A normal DEL will not work in this case because the cluster still has the correct hash-slot ownership information. So simply sending DEL will get you redirected to the correct node and delete the good key.
Instead, we need to flag the connection with -ASK first, which, as stated in the documentation, will not get us a redirection

ASK means to send only the next query to the specified node.

We can test this out by GETting key 515 (which we SET a new value for earlier)

The downside to this is that since -ASK only affects the next query, we will have to set it again after completing one command

 

So, you can delete the errant key by running ASKING followed by DEL command

Conclusion

Loading the wrong RDB file into a Redis Cluster node can leave keys from other shards behind, wasting memory and causing operational headaches. While Redis 8.6 and later automatically clean up these misplaced keys, older versions require manual intervention. If the correct RDB file is still available and no new data has been written, restoring it is the simplest solution. Otherwise, you can identify the affected slots using redis-cli –cluster check, locate the misplaced keys with CLUSTER COUNTKEYSINSLOT and CLUSTER GETKEYSINSLOT, and safely remove them using ASKING followed by DEL. Most importantly, always verify that you are deleting keys from the affected node rather than their rightful owner to avoid accidental data loss.

 

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved