Bug 78337 - journald can be very slow (on btrfs ?)
Summary: journald can be very slow (on btrfs ?)
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-06 12:42 UTC by Mildred Ki'Lya
Modified: 2015-02-11 19:49 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
ls -l output (23.42 KB, text/plain)
2014-05-06 12:42 UTC, Mildred Ki'Lya
Details
journalctl --verify command output (85.43 KB, text/plain)
2014-05-06 12:43 UTC, Mildred Ki'Lya
Details

Description Mildred Ki'Lya 2014-05-06 12:42:42 UTC
Created attachment 98555 [details]
ls -l output

I used journald in both Fedora and ArchLinux, on a btrfs filesystem, and I noticed on two occasions (once for each distribution) that journald can become very slow, to the point where the boot proess is taking a very long time (more than 10 minutes).

After getting a shell, I found that I couldn't access the log at all. Or it took a very long time (a few minutes for `journalctl -fa`).

Removing (or moving away) all files in /var/log/journal fixed the problem and the system was as fast as the first day.

I still have the old files for diagnosis if you want me to try something with them.

Here is the output of --verify and --disk-usage

$ journalctl -D /var/log/journal/e92df66897d24a499a6b6ecf7e6a30c2- --disk-usage
Journals take up 4.0G on disk.

The output of --verify command (that was successful) and the list of files is attached.
Comment 1 Mildred Ki'Lya 2014-05-06 12:43:17 UTC
Created attachment 98556 [details]
journalctl --verify command output
Comment 2 Radek Podgorny 2014-06-05 08:05:07 UTC
the problem is btrfs fragmentation. try using autodefrag mount option and/or manual defrag.
Comment 3 Radek Podgorny 2014-06-05 08:06:31 UTC
btw, you can diagnose this using:

sudo filefrag /var/log/journal/*/*
Comment 4 Lennart Poettering 2015-02-04 18:56:36 UTC
journald in git will now automatically set the NOCOW flag for journal files, and issues btrfs defrag calls when it archives journal files. With that in place journald hsould provide similar performance on btrfs as on other file systems.
Comment 5 Radek Podgorny 2015-02-04 22:44:55 UTC
ok, nice! but is it safe? wouldn't the journal be damaged on sudden power failure, then? (and logs are usually the most important thing to have when anything goes wrong)
Comment 6 Lennart Poettering 2015-02-11 19:49:05 UTC
(In reply to Radek Podgorny from comment #5)
> ok, nice! but is it safe? wouldn't the journal be damaged on sudden power
> failure, then? (and logs are usually the most important thing to have when
> anything goes wrong)

With the NOCOW flag set data integrity guarantees on btrfs degrade to the same ones made by ext3/4 which should be pretty much OK. Also, the journal does its own checksumming, and hence should be capable of detecting corruptions (though not fixing them). Given that we have a "mostly append + update ptrs at front" write pattern the expected data loss if some writes are missing or written in the wrong order should be limited: either the pointers are missing but the appended data written, in which case the appended data will simply not be considered but everything else is OK. Or the data is missing and the pointers set up, for which case we have careful checks in place. 

All in all I think we should be OK.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.