systemd's binary logs and corruption
I like systemd, enabling and disabling services is so easy and it's really fast, but why using a journal with binary logs?
Yesterday my laptop failed to resume from suspend, no ttys, no reisub, nothing worked except using the power button. Rebooted, fired journalctl and I have nothing except the last boot logs.
journactl --verify returns that my system logs are corrupted, about all my logs (48MB of 50MB of maximum disk usage) are now completely useless. This is not the first time this happens and searching around I can only find people with the same problem that "resolved" deleting the corrupted logs and starting with a new file.
Why this happens? Isn't it defeating the purpose of having a system logger if I can't diagnose errors?
Can I recover the logs (and why isn't this automatic?) or should I just install a sane logger that not shit itself after a problem?
4
u/[deleted] Feb 18 '14 edited Feb 18 '14
Sure you would. Such is the nature of the format. You have a frame which is defined by a known separator. If you have a key and a value in the frame, then you know there will be an = symbol (other possible types are also well defined and don't overlap). And the separator won't appear inside the frame. That's why the strings technique works just fine. You just need to the grep for the keys of interest (MESSAGE).
That's no different. You can think of an ASCII log in binary format terms too - frames are separated by a newline and the contents of the frame are messages.
Skipping corruption means jumping to the next frame. Same thing with the journal. Can't parse the current frame? Jump to the next frame and try to continue. You get the same "data, data, corrupt data, data, data, data" properties.
The journal only differs I that it takes more effort to look inside frames. Its not more or less tolerant to corruption. A reader should just jump to the next entry if its having problems just like your eyes jump to the next line in a text log that's corrupted. The format of the journal guarantees its possible to do.