Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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. Resque
$ redis-cli
> config set stop-writes-on-bgsave-error no
@nmiano1111

This comment has been minimized.

Copy link

@nmiano1111 nmiano1111 commented Feb 11, 2014

This is a godsend!

@appel268576

This comment has been minimized.

Copy link

@appel268576 appel268576 commented Apr 28, 2015

👍

@javierrodriguez9

This comment has been minimized.

Copy link

@javierrodriguez9 javierrodriguez9 commented May 25, 2015

Thank you!! :)

@viguza

This comment has been minimized.

Copy link

@viguza viguza commented May 25, 2015

According to Redis documentation, this is recommended only if you don't have RDB snapshots enabled or if you don't care about data persistence in the snapshots.

"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."

Here you can find a redis.config example with more info about that option.

@TodiRishika

This comment has been minimized.

Copy link

@TodiRishika TodiRishika commented Jun 17, 2016

Thanks!

@bakhodur-kandikov

This comment has been minimized.

Copy link

@bakhodur-kandikov bakhodur-kandikov commented Jun 28, 2016

++++++

@erdemoflaz

This comment has been minimized.

Copy link

@erdemoflaz erdemoflaz commented Jan 28, 2017

baba adamsın :)))

@antirez

This comment has been minimized.

Copy link

@antirez antirez commented Jan 31, 2017

It's advisable to find the root reason why the server is not able to persist the RDB file on disk. Disabling the option may have the unfortunate effect of a serious persistence problem to be undetected until the last reboot, when the DB will restart wiped or with old data.

@mhipo1364

This comment has been minimized.

Copy link

@mhipo1364 mhipo1364 commented Feb 1, 2017

👍

@summerblue

This comment has been minimized.

Copy link

@summerblue summerblue commented May 16, 2017

What u should be doing is :

# redis-cli
127.0.0.1:6379> CONFIG SET dir /data/tmp
OK
127.0.0.1:6379> CONFIG SET dbfilename temp.rdb
OK
127.0.0.1:6379> BGSAVE
Background saving started
127.0.0.1:6379>

Please Make sure /data/tmp has enough disk space.

@oleole90

This comment has been minimized.

Copy link

@oleole90 oleole90 commented Sep 18, 2017

@summerblue thanks a bunch!

@JamesNock

This comment has been minimized.

Copy link

@JamesNock JamesNock commented Jan 24, 2018

Legend!

@adet4ever

This comment has been minimized.

Copy link

@adet4ever adet4ever commented Feb 8, 2018

@summerblue
Some people are saying not to run config set stop-writes-on-bgsave-error no. However, I do not see why this problem is occuring on my new server, given it does not happen on the old server. The redis installation uses all default settings with dir located at: /var/lib/redis/6379

The issue happens intermittently and dont know why. no indication in the logs.
Your comment said to make sure the data dir has enough disk space. Wouldnt that grow to the limit of the disk space on the server?
Is there a max limit per folder?

@drarnold

This comment has been minimized.

Copy link

@drarnold drarnold commented Mar 21, 2018

This SAVED our team! Thanks for putting this up!

@JoseCage

This comment has been minimized.

Copy link

@JoseCage JoseCage commented Mar 26, 2018

Thanks. That worked for me.

@npyramid

This comment has been minimized.

Copy link

@npyramid npyramid commented Mar 30, 2018

thanks

@mattcollier

This comment has been minimized.

Copy link

@mattcollier mattcollier commented Apr 9, 2018

@adet4ever do you have any information about your redis server intermittently failing on bgsave? What redis version are you using?

For my part, I am doing some fault-tolerance checks that involve restarting our nodejs application (only) repeatedly. With redis 4.0.9 (from the Chris Lea PPA), after around restart 40 iterations, redis starts reporting that it had difficulty persisting to disk. There are no permission issues or disk space issues. After I see the error, I can issue a bgsave CLI command and it succeeds. I can see that the timestamp on the rdb file is updated etc. There is nothing exceptional about the size of my rdb file (typically around 10M).

I have found that if I roll back to redis 3.0.6 from the Ubuntu Xenial repository, I do not see this issue.

@wagner-certat

This comment has been minimized.

Copy link

@wagner-certat wagner-certat commented May 11, 2018

@mattcollier Does this help? https://stackoverflow.com/a/49839193/2851664

In short: Redis forks in order to save the snapshot. If the kernel is not allowed to overcommit the memory, the needed memory is doubled and the OOM killer might need to kill the process -> allow overcommitting.

And in all cases: look at the logs of redis and the kernel.

@skbailey

This comment has been minimized.

Copy link

@skbailey skbailey commented Aug 3, 2018

Thank you! ❤️

@sadfuzzy

This comment has been minimized.

Copy link

@sadfuzzy sadfuzzy commented Aug 7, 2018

🥇

@HuyenCherry

This comment has been minimized.

Copy link

@HuyenCherry HuyenCherry commented Oct 3, 2018

tkank you

@mohsinahmed22

This comment has been minimized.

Copy link

@mohsinahmed22 mohsinahmed22 commented Oct 8, 2018

Thank you its works fine.....

@blind3dd

This comment has been minimized.

Copy link

@blind3dd blind3dd commented Oct 9, 2018

Okay thanking in advance - I just know it will work :D The best :D

@StanSilas

This comment has been minimized.

Copy link

@StanSilas StanSilas commented Oct 22, 2018

It worked. Lifesaver!

@abhisheksarka

This comment has been minimized.

Copy link

@abhisheksarka abhisheksarka commented Nov 30, 2018

I checked the Redis logs which lead me to "Can't save in background: fork: Cannot allocate memory". This in turn lead me to this

Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits. In theory the child should use as much memory as the parent being a copy, but actually thanks to the copy-on-write semantic implemented by most modern operating systems the parent and child process will share the common memory pages. A page will be duplicated only when it changes in the child or in the parent. Since in theory all the pages may change while the child process is saving, Linux can't tell in advance how much memory the child will take, so if the overcommit_memory setting is set to zero fork will fail unless there is as much free RAM as required to really duplicate all the parent memory pages, with the result that if you have a Redis dataset of 3 GB and just 2 GB of free memory it will fail.

Setting overcommit_memory to 1 says Linux to relax and perform the fork in a more optimistic allocation fashion, and this is indeed what you want for Redis.

@abhisheksarka

This comment has been minimized.

Copy link

@abhisheksarka abhisheksarka commented Nov 30, 2018

Make sure to set the Linux kernel overcommit memory setting to 1. Add vm.overcommit_memory = 1 to /etc/sysctl.conf and then reboot or run the command sysctl vm.overcommit_memory=1 for this to take effect immediately. https://redis.io/topics/admin

@angeldev20

This comment has been minimized.

Copy link

@angeldev20 angeldev20 commented Jan 11, 2019

Thank you.

@Sphinxs

This comment has been minimized.

Copy link

@Sphinxs Sphinxs commented Feb 22, 2019

Thanks ( :

@bhavinjr

This comment has been minimized.

Copy link

@bhavinjr bhavinjr commented Mar 15, 2019

Working 👍

@gabmontes

This comment has been minimized.

Copy link

@gabmontes gabmontes commented Mar 21, 2019

Thanks!

@iamrexan

This comment has been minimized.

Copy link

@iamrexan iamrexan commented Jun 28, 2019

@summerblue when i increase the disk size is again get full .how i can solve this.

@Nleuchter

This comment has been minimized.

Copy link

@Nleuchter Nleuchter commented Nov 26, 2019

Thanks bro

@nasrulhazim

This comment has been minimized.

Copy link

@nasrulhazim nasrulhazim commented Dec 18, 2019

thanks!

@mikgn

This comment has been minimized.

Copy link

@mikgn mikgn commented Dec 19, 2019

Thanks!

@jpcmf

This comment has been minimized.

Copy link

@jpcmf jpcmf commented Apr 16, 2020

Works!

@Nevillealee

This comment has been minimized.

Copy link

@Nevillealee Nevillealee commented Apr 30, 2020

Still works!

@FernandoBello

This comment has been minimized.

Copy link

@FernandoBello FernandoBello commented May 10, 2020

Great ! 👍

@ingemar

This comment has been minimized.

Copy link

@ingemar ingemar commented Jun 15, 2020

Thank you!

@jPingua

This comment has been minimized.

Copy link

@jPingua jPingua commented Jun 23, 2020

I encountered this issue and my senior was unreachable. I thought I was booked for the day, but this code helped me fix the issue in minutes.

@Barolina

This comment has been minimized.

Copy link

@Barolina Barolina commented Aug 27, 2020

++++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.