Bug 979487

Summary: sd_journal_seek_tail doesn't go to end
Product: [Fedora] Fedora Reporter: Frank Ch. Eigler <fche>
Component: systemdAssignee: systemd-maint
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 23CC: jfilak, johannbg, jsynacek, lnykryn, msekleta, net147, plautrba, rvokal, systemd-maint, theinric, vpavlin, zbyszek
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-10-20 12:59:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Frank Ch. Eigler 2013-06-28 16:19:37 UTC
On systemd 201 (f18) and 204 (rawhide), the attached toy program loops for quite a while, consuming journald entries immediately after it did an sd_journal_seek_tail(), to go to the last entry.  It's as though the tail sought is not the real final entry (systemwide), though not the head either.


% cat sample.c
#include <systemd/sd-journal.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>


void main(int argc, char *argv[]) {
  sd_journal* journald_context;
  int count;
  int rc;

  rc = sd_journal_open(& journald_context, 0);
  assert (rc == 0);
  if (argc == 2 && !strcmp(argv[1],"tail"))
    rc = sd_journal_seek_tail(journald_context);
  else if (argc == 2 && !strcmp(argv[1],"head"))
    rc = sd_journal_seek_head(journald_context);
  else
    rc = 0;
  assert (rc == 0);

  for (count=0 ; ; count++) {
    char *cursor;
    rc = sd_journal_next(journald_context);
    assert (rc >= 0);
    if (rc == 0) break;
    rc = sd_journal_get_cursor(journald_context, &cursor);
    assert (rc == 0);
    printf ("#%d: cursor %s\n", count, cursor);
    free (cursor);
  }
}

% gcc sample.c -lsystemd-journal
% a.out head | wc -l
--- expecting this to be a large number; on my f18 workstation, 189350
% a.out tail | wc -l
--- expecting this to be near-zero; on my f18 workstation, 188492

Comment 1 Fedora End Of Life 2013-09-16 14:17:49 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 20 development cycle.
Changing version to '20'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora20

Comment 2 Frank Ch. Eigler 2013-10-03 14:29:11 UTC
I found that adding a sd_journal_previous_skip (..., 1) call after
the sd_journal_seek_tail (like journalctl -f does) makes things work.
It would be nice if this workaround were not necessary (or else
documented).

Comment 3 Jakub Filak 2014-06-30 15:23:01 UTC
The sd_journal_seek_tail() works as expected with systemd-208-11.el7.x86_64,
but does not work with systemd-208-19.fc20.x86_64 and systemd-214-4.fc21.x86_64.

Comment 4 Fedora End Of Life 2015-05-29 09:08:30 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Fedora End Of Life 2015-06-29 12:01:58 UTC
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 6 Jan Kurik 2015-07-15 14:47:18 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 23 development cycle.
Changing version to '23'.

(As we did not run this process for some time, it could affect also pre-Fedora 23 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 23 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora23

Comment 7 Jan Synacek 2015-10-20 12:59:50 UTC
This is fixed on F23.

$ ./a.out head | wc -l
809933

$ ./a.out tail | wc -l
56

$ rpm -q systemd
systemd-222-7.fc23.x86_64