Skip to content

loads empty AOF instead of rdb #1826

Closed
Closed

Description

@tj

just enabling the AOF after we had been using the instance for a while, seems weird that it would favour an empty file over the rdb, what's the recommended way to trick it into loading the rdb at least the first time and then having it write to the AOF?

cheers

Activity

  1. charsyam commented on Jun 19, 2014

    @charsyam
    Contributor

    @visionmedia if you enable AOF and RDB. Redis will choose AOF load not RDB.

  2. antirez commented on Jun 19, 2014

    @antirez
    Contributor

    Hello, just set appendonly no in the Redis config file, restart, to enable AOF do:

    • CONFIG SET appendonly yes.
    • CONIFIG REWRITE (or, manually alter the config to set it to yes).

    Done.

  3. tj commented on Jun 19, 2014

    @tj
    ContributorAuthor

    nvm, config set appendonly yes does the trick

  4. tj commented on Jun 19, 2014

    @tj
    ContributorAuthor

    oh didn't refresh hahaha thanks for the quick answer

  5. antirez commented on Jun 19, 2014

    @antirez
    Contributor

    yw ;-)

  6. antirez commented on Jun 19, 2014

    @antirez
    Contributor

    p.s. remember to rewrite or alter the config, otherwise the next restart you'll have a bad surprise.

  7. yihuang commented on Jun 21, 2014

    @yihuang
    Contributor

    We've met a problem, we had an instance running for a while, then we

    • CONFIG SET appendonly yes
    • CONIFIG REWRITE

    then we restart, we found data is lost. I think maybe because the aof file don't contains all the data?

  8. antirez commented on Jun 21, 2014

    @antirez
    Contributor

    @yihuang I don't think so, probably the config rewrite failed? If AOF is not able to accept writes Redis returns errors on writes. It's more likely that rewrite reported an unnoticed error and on restart there was still the old config supposed to load an RDB file.

  9. yihuang commented on Jun 21, 2014

    @yihuang
    Contributor

    @antirez I known what happened, we shutdown redis server immediately after set aof, then the aof file is left incomplete. I just reproduced it.

    $ redis-cli -p 10004 CONFIG SET appendonly yes && redis-cli -p 10004 CONFIG rewrite && sudo /etc/init.d/redis_10004 stop
    OK
    OK
    Stopping ...
    Redis stopped
    $ ls /var/lib/redis/10004 -l
    -rw-r--r-- 1 root root        0  6月 21 16:43 appendonly.aof
    -rw-r--r-- 1 root root 19929490  6月 21 16:43 dump.rdb
    -rw-r--r-- 1 root root   761856  6月 21 16:43 temp-rewriteaof-20486.aof
    

    This is the log:

    [20428] 21 Jun 16:42:55.537 * DB saved on disk
    [20428] 21 Jun 16:42:55.538 * RDB: 0 MB of memory used by copy-on-write
    [20109] 21 Jun 16:42:55.578 * Background saving terminated with success
    [20109] 21 Jun 16:43:30.741 * Background append only file rewriting started by pid 20486
    [20109] 21 Jun 16:43:30.747 # CONFIG REWRITE executed with success.
    [20109] 21 Jun 16:43:30.756 # User requested shutdown...
    [20109] 21 Jun 16:43:30.756 # There is a child rewriting the AOF. Killing it!
    [20109] 21 Jun 16:43:30.756 * Calling fsync() on the AOF file.
    [20109] 21 Jun 16:43:30.931 * Saving the final RDB snapshot before exiting.
    [20109] 21 Jun 16:43:31.910 * DB saved on disk
    [20109] 21 Jun 16:43:31.910 * Removing the pid file.
    [20109] 21 Jun 16:43:31.910 # Redis is now ready to exit, bye bye...
    
  10. yihuang commented on Jun 21, 2014

    @yihuang
    Contributor

    I guess shutdown should wait for aof rewriting process exit.

  11. antirez commented on Jun 21, 2014

    @antirez
    Contributor

    @yihuang normally shutting down during AOF rewrite is safe, but once you enable it, your initial AOF is non-existing, so you need to wait for the rewrite to end actually. Btw this may well be considered a bug, in which, probably Redis should refuse to shutdown if there is a rewrite in progress that is the initial rewrite after the switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions