• chenyang8094's avatar
    Fix auto-aof-rewrite-percentage based AOFRW trigger after restart (#10550) · 625bdaf3
    chenyang8094 authored
    
    
    The `auto-aof-rewrite-percentage` config defines at what growth percentage
    an automatic AOF rewrite is triggered.
    This normally works OK since the size of the AOF file at the end of a rewrite
    is stored in `server.aof_rewrite_base_size`.
    However, on startup, redis used to store the entire size of the AOF file into that
    variable, resulting in a wrong automatic AOF rewrite trigger (could have been
    triggered much later than desired).
    This issue would only affect the first AOFRW after startup, after that future AOFRW
    would have been triggered correctly.
    This bug existed in all previous versions of Redis.
    
    This PR unifies the meaning of `server.aof_rewrite_base_size`, which only represents
    the size of BASE AOF.
    Note that after an AOFRW this size includes the size of the incremental file (all the
    commands that executed during rewrite), so that auto-aof-rewrite-percentage is the
    ratio from the size of the AOF after rewrite.
    However, on startup, it is complicated to know that size, and we compromised on
    taking just the size of the base file, this means that the first rewrite after startup can
    happen a little bit too soon.
    Co-authored-by: default avatarOran Agra <oran@redislabs.com>
    Co-authored-by: default avataryoav-steinberg <yoav@redislabs.com>
    625bdaf3
aof.c 94.1 KB