Hello Jay,
On Wed, Dec 3, 2014 at 10:12 PM, Jay Rolette <
rol...@infiniteio.com> wrote:
> I would have expected this case to be covered by aof-load-truncated, but
> looking at aof.c, it only does the auto truncate if we were in the middle of
> a MULTI/EXEC transaction. Any chance it can be called in cases like this?
Actually the code behavior is a bit different. I understand that it's
a bit convoluted and at a first glance it seems like you said. But
actually it always loads the AOF file if it is truncated without
garbage at the end.
> I'm also curious about the block of NULLs at the end. I've started having my
> guys ping me to look at the AOF file when this happens and it's relatively
> consistent. No partially written commands, just a bunch of NULLs (and
> sometimes a newline) at the end of the AOF file.
The NULLs are the end is the reason Redis is not able to load the
file, basically: it detects it as garbage so refuses to start.
> Side-effect of how Redis writes to the AOF file maybe? I haven't had a
> chance to look at that part of the code, but it smells like maybe it is
> writing out a fixed size buffer and then calling truncate() to trim the file
> back to the correct size.
No... Redis business with AOF is just to append via write(2). I
believe the problem is that metadata of the file has no chance to get
updated so somewhat we see a partial empty block at the end of the
file.
This should be filesystem implementation specific. So basically the
problem to fix is this one... one time it could be zero-padded, but
other times it could be full of garbage maybe, not sure.
To make aof loading safe we can allow truncations but not malformed data.
Cheers,
Salvatore
--
Salvatore 'antirez' Sanfilippo
open source developer - GoPivotal
http://invece.org
"Fear makes the wolf bigger than he is."
— German proverb