Bug 86855

Summary: Reading journal backwards misses entries
Product: systemd Reporter: Olivier Brunel (jjacky) <jjk>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: major    
Priority: medium CC: amanduch
Version: unspecified   
Hardware: Other   
OS: All   
See Also: https://bugs.freedesktop.org/show_bug.cgi?id=83912
Whiteboard:
i915 platform: i915 features:

Description Olivier Brunel (jjacky) 2014-11-29 16:39:44 UTC
Simple illustration of the problem:

% coredumpctl list COREDUMP_PID=8212   
TIME                            PID   UID   GID SIG PRESENT EXE
Sat 2014-11-29 13:17:03 CET    8212  1000   100   6 * /usr/bin/Xorg.bin

% coredumpctl list -1 COREDUMP_PID=8212
No match found.


The reason it fails to find a match with -1 is that then sd_journal_seek_tail()/sd_journal_previous() are used, else it's be seek_head()/next(); and apparently going backwards doen't work right.

As a test, I did a small program that uses similar matches (COREDUMP_PID=8212 AND MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1), if the loop with the call to sd_journal_get_data() is done with SD_JOURNAL_FOREACH(j) it works, with SD_JOURNAL_FOREACH_BACKWARDS(j) no matches are found.

Trying using another set of matches (on a COREDUMP_EXE this time), I get 13 matches going forward, only 12 going backwards.

No idea what's going on, but clearly going backwards in the journal doesn't work properly.

This is on up-to-date Arch Linux x86_64:
% systemctl --version
systemd 217
+PAM -AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID -ELFUTILS +KMOD +IDN
Comment 1 Lennart Poettering 2014-12-08 18:24:32 UTC
Fixed in git, with your patch! Thanks!

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.