Skip to content

Minimum save interval when saving fails #849

Closed

Description

@p

Suppose the rdb file is not writable for whatever reason.

Redis goes into a spin trying to save its data.

Here is a log excerpt for a single second of wallclock time: http://paste.kde.org/631532/

In this one second, redis attempted the write 63 times.

It also produced 18 kb of log entries which, unlike the data, were written to disk.

There is absolutely no reason to try to save any more frequently than once per second. In the configuration file it does not appear to be possible to specify a shorter save interval, so you can assume that users are ok with at least that much data loss.

In practice, save intervals can be way more than one second. This is what I have in my file which came as a default:

save 900 1
save 300 10
save 60 10000

You can probably retry saves after errors at the shortest interval, in this case once a minute. This feels weird coming from a world that cares about one's data, but the configuration above says that up to the last minute of data can be discarded at any time. Why are write errors more significant than other issues?

If you for whatever reason want to have a shorter retry interval on errors, 5x as frequent as the shortest configured interval, but no more frequent than once per second, ought to be a reasonable choice.

redis-2.6.7

Activity

  1. antirez commented on Jan 21, 2013

    @antirez
    Contributor

    Hello @p, I think you are very right and very wrong at the same time :-)

    You are absolutely right, there is no excuse to fill the logs like that trying to save al every serverCron() call. it's simply stupid and should be avoided at all. It can create huge problems, load, fill the disk. BAD, I'll fix it as soon as I end writing this reply to you.

    However you are wrong IMHO with the idea that if you can persist one time ever minute, then, "Hey it's not serious persistence! I can persiste every two minutes and it's the same".

    If you guaranteed the user you are going to persist every 60 seconds, then better you try to make the delay as short as possible if there are problems that are possibly are transient. Once the issue is solved, we want to persist ASAP to honor the guarantee.

    IMHO a reasonable behavior is the following:

    • If last save failed, wait at least a small number of seconds, like 5, in order to try again.
    • If the incident was logged, wait at least another minute before logging the error again, in the meantime increment a counter so you can log "Save failed 10 times in the latest minute" when finally you can log the issue.

    I'll try to turn this into some reasonable code ASAP. Thank you. Keeping the issue open until I commit the code.

  2. p commented on Jan 21, 2013

    @p
    Author

    Sounds like a reasonable solution.

  3. antirez commented on Apr 2, 2013

    @antirez
    Contributor

    Fixed, sorry for the delay.

  4. p commented on Apr 2, 2013

    @p
    Author

    Thanks!

  5. added a commit that references this issue on Jul 28, 2025
  6. added a commit that references this issue on Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions