others-how to resolve 'MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk' error when using spring redis?

1. Purpose

In this post, I would demonstrate how to resolve the following error when using spring redis template:

Caused by: redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.


2. The solution

2.1 The details of the problem

The detail of the problem is:

2022-02-16 17:51:47.958  INFO 3913 --- [Thread-6] com.bswen.wx.service.WxCheckThread      : delete mykey cache of 20220213,key=redis.mykey.cachemap.20220213
2022-02-16 17:51:47.958 ERROR 3913 --- [Thread-6] com.bswen.wx.service.WxCheckThread      :

org.springframework.dao.InvalidDataAccessApiUsageException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.; nested exception is redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
        at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:44)
        at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:36)
        at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:37)
        at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:37)
        at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:195)
        at org.springframework.data.redis.connection.jedis.JedisConnection.del(JedisConnection.java:713)
        at org.springframework.data.redis.connection.DefaultStringRedisConnection.del(DefaultStringRedisConnection.java:210)
        at org.springframework.data.redis.core.RedisTemplate$4.doInRedis(RedisTemplate.java:602)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:190)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152)
        at org.springframework.data.redis.core.RedisTemplate.delete(RedisTemplate.java:599)
        at com.bswen.wx.service.WxCheckThread.checkmykeyCache(WxCheckThread.java:85)
        at com.bswen.wx.service.WxCheckThread.run(WxCheckThread.java:65)
Caused by: redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
        at redis.clients.jedis.Protocol.processError(Protocol.java:113)
        at redis.clients.jedis.Protocol.process(Protocol.java:131)
        at redis.clients.jedis.Protocol.read(Protocol.java:200)
        at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:285)
        at redis.clients.jedis.Connection.getIntegerReply(Connection.java:210)
        at redis.clients.jedis.BinaryJedis.del(BinaryJedis.java:161)
        at org.springframework.data.redis.connection.jedis.JedisConnection.del(JedisConnection.java:711)
        ... 7 common frames omitted

2022-02-16 17:53:34.589  INFO 3913 --- [Thread-4] com.bswen.wx.service.EmailCheckThread   : email CheckThread start checking now...
2022-02-16 17:53:34.590  INFO 3913 --- [Thread-4] com.bswen.wx.service.EmailCheckThread   : email CheckThread got 0 missed tasks to process.
2022-02-16 17:53:34.590  INFO 3913 --- [Thread-4] com.bswen.wx.service.EmailCheckThread   : email CheckThread end check
2022-02-16 17:53:47.963  INFO 3913 --- [Thread-6] com.bswen.wx.service.WxCheckThread      : WxCheckThread start checking now...
2022-02-16 17:53:47.964  INFO 3913 --- [Thread-6] com.bswen.wx.service.WxCheckThread      : WxCheckThread got 0 missed tasks to process.
2022-02-16 17:53:47.964  INFO 3913 --- [Thread-6] com.bswen.wx.service.WxCheckThread      : delete mykey cache of 20220213,key=redis.mykey.cachemap.20220213
2022-02-16 17:53:47.964 ERROR 3913 --- [Thread-6] com.bswen.wx.service.WxCheckThread      :

org.springframework.dao.InvalidDataAccessApiUsageException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.; nested exception is redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
        at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:44)
        at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:36)
        at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:37)
        at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:37)
        at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:195)
        at org.springframework.data.redis.connection.jedis.JedisConnection.del(JedisConnection.java:713)
        at org.springframework.data.redis.connection.DefaultStringRedisConnection.del(DefaultStringRedisConnection.java:210)
        at org.springframework.data.redis.core.RedisTemplate$4.doInRedis(RedisTemplate.java:602)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:190)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152)
        at org.springframework.data.redis.core.RedisTemplate.delete(RedisTemplate.java:599)
        at com.bswen.wx.service.WxCheckThread.checkmykeyCache(WxCheckThread.java:85)
        at com.bswen.wx.service.WxCheckThread.run(WxCheckThread.java:65)
Caused by: redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
        at redis.clients.jedis.Protocol.processError(Protocol.java:113)
        at redis.clients.jedis.Protocol.process(Protocol.java:131)
        at redis.clients.jedis.Protocol.read(Protocol.java:200)
        at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:285)
        at redis.clients.jedis.Connection.getIntegerReply(Connection.java:210)
        at redis.clients.jedis.BinaryJedis.del(BinaryJedis.java:161)
        at org.springframework.data.redis.connection.jedis.JedisConnection.del(JedisConnection.java:711)
        ... 7 common frames omitted



2.2 The debug of the problem

I found that the rdb file of my redis instance is very large. So I tried to parse it with a tool named redis data retrieve tool or rdr: , you can refer to this document to do the redis dump file parse job.

After analyzing the above image, I found that there are too many sortedsets in my redis buffer, so I tried to delete them and restarted redis.

2.3 The solution

Make sure the following configuration exists in your redis.conf, you can change it to “no” if you want to serve requests even if the background saving task fails.

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
stop-writes-on-bgsave-error yes # change it to no if you want to serve requests

And make sure that your redis dump rdb file is small and the backround saving is not too long.

2.4 Other resources

You can also refer to this thread to solve your problem.


3. Summary

In this post, I demonstrated how to debug the MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk problem , the key point is to use rdr tool to analyze your redis dump file and keep it small. That’s it, thanks for your reading.

-->