ERROR: LOADING Redis is loading the dataset in memory.
This Redis error is shown when the system is not ready to accept connection requests. It usually goes away when Redis finishes loading data into the memory, but sometimes it persists.
As a part of our Server Management Services, we help our customers to fix Redis related errors like this.
Today we’ll take a look at what causes persistent memory errors, and how to fix it.
What causes “ERROR: LOADING Redis is loading the dataset in memory”?
Redis keeps the whole data set in memory and answers all queries from memory. This often helps to reduce the application load time.
The Redis replication system allows replica Redis instances to be exact copies of master instances. The replica will automatically reconnect to the master every time the link breaks and will attempt to be an exact copy of it regardless of what happens to the master.
As updated earlier “LOADING Redis is loading the dataset in memory” error occurs if connections requests reach before the system completely loads the dataset into memory and makes Redis ready for connections. This generally happens in two different scenarios:
- At a master startup.
- When a slave reconnects and performs a full resynchronization with a master.
Let us now look at the possible fixes for this error.
How to fix the error “LOADING Redis is loading the dataset in memory”?
In most cases, a frequent display of the error message can be related to some recent changes made on the site in relation to Redis. This may increase the data in Redis considerably and can get saturated easily. As a result, Redis replicas may disconnect frequently. Finally, when it tries to reconnect the message “LOADING Redis is loading the dataset in memory” may be displayed.
The quick solution here would be to flush the Redis cache. Lets us discuss on how to fix the Redis cache:
Flush Redis Cache
To Flush the Redis Cache, either the FLUSHDB or the FLUSHALL commands could be used. FLUSHDB command deletes all the keys of the DBs selected and the FLUSHALL command deletes all the keys of all the existing databases, not just the selected one.
The syntax for the commands are:
redis-cli FLUSHDB
redis-cli -n DB_NUMBER FLUSHDB
redis-cli -n DB_NUMBER FLUSHDB ASYNC
redis-cli FLUSHALL
redis-cli FLUSHALL ASYNC
For instance, to delete all the keys of a database #4 from the Redis cache, the syntax to be used is:
$ redis-cli -n 4 FLUSHDB
This will help to fix the issue. To prevent it from happening frequently, we need to revert the changes that were made earlier. It is always preferred to keep the information within Redis minimalistic.
[Need help to fix Redis errors? We are available 24×7]
Conclusion
In short, the error “LOADING Redis is loading the dataset in memory” occurs at Redis master startup or when the slave reconnects and performs a full resynchronization with master. When these connections requests reach before the dataset is completely loaded into memory, it triggers the error message. Today, we discussed how our Support Engineers fix this error.
0 Comments