abrt-journal: First seek the journal tail and then set filters

Resolves: rhbz#2128662

Signed-off-by: Michal Srb <michal@redhat.com>
This commit is contained in:
Michal Srb 2022-10-19 15:41:54 +02:00
parent c8a122775e
commit a20ba81e1d
2 changed files with 67 additions and 1 deletions

View File

@ -0,0 +1,61 @@
From 428bdf417b33d65fa5fbdcd292f12eef704bae95 Mon Sep 17 00:00:00 2001
From: Michal Srb <michal@redhat.com>
Date: Wed, 19 Oct 2022 06:43:38 +0200
Subject: [PATCH] a-dump-journal-core: First seek the journal tail and then set
filters
See: rhbz#2128662
a-dump-journal-core uses filters to jump between
systemd-coredump entries in journal.
However, we should first jump to the starting position
(journal tail) and only then set filters.
I suspect that setting the filters early, before we are
at the starting position, can lead to the strange
behavior that we are seeing in Fedora.
This patch makes the problem go away on my freshly-installed
Fedora 37 VM.
Signed-off-by: Michal Srb <michal@redhat.com>
---
src/plugins/abrt-dump-journal-core.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/plugins/abrt-dump-journal-core.c b/src/plugins/abrt-dump-journal-core.c
index 68d5b320..1bb793a2 100644
--- a/src/plugins/abrt-dump-journal-core.c
+++ b/src/plugins/abrt-dump-journal-core.c
@@ -628,17 +628,22 @@ main(int argc, char *argv[])
error_msg_and_die(_("Cannot open systemd-journal"));
}
- if (abrt_journal_set_journal_filter(journal, coredump_journal_filter) < 0)
- error_msg_and_die(_("Cannot filter systemd-journal to systemd-coredump data only"));
+ if (opts & OPT_e) {
+ if (abrt_journal_seek_tail(journal) < 0)
+ error_msg_and_die(_("Cannot seek to the end of journal"));
- g_list_free(coredump_journal_filter);
-
- if ((opts & OPT_e) && abrt_journal_seek_tail(journal) < 0)
- error_msg_and_die(_("Cannot seek to the end of journal"));
+ if (abrt_journal_save_current_position(journal, ABRT_JOURNAL_WATCH_STATE_FILE) < 0)
+ log_warning("Failed to save the starting cursor position");
+ }
if (cursor && abrt_journal_set_cursor(journal, cursor))
error_msg_and_die(_("Failed to set systemd-journal cursor '%s'"), cursor);
+ if (abrt_journal_set_journal_filter(journal, coredump_journal_filter) < 0)
+ error_msg_and_die(_("Cannot filter systemd-journal to systemd-coredump data only"));
+
+ g_list_free(coredump_journal_filter);
+
if ((opts & OPT_f))
{
if (!cursor && !(opts & OPT_e))
--
2.37.3

View File

@ -49,13 +49,14 @@
Summary: Automatic bug detection and reporting tool
Name: abrt
Version: 2.15.1
Release: 5%{?dist}
Release: 6%{?dist}
License: GPLv2+
URL: https://abrt.readthedocs.org/
Source: https://github.com/abrt/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
Patch0: 0001-Fix-for-rpm-4.18.patch
Patch1: 0002-abrt-journal-call-sd_journal_get_fd-right-after-sd_j.patch
Patch2: 0003-applet-Update-GLib-constant-name.patch
Patch3: 0004-a-dump-journal-core-First-seek-the-journal-tail-and-.patch
BuildRequires: git-core
BuildRequires: %{dbus_devel}
@ -1010,6 +1011,10 @@ killall abrt-dbus >/dev/null 2>&1 || :
%config(noreplace) %{_sysconfdir}/profile.d/abrt-console-notification.sh
%changelog
* Wed Oct 19 2022 Michal Srb <michal@redhat.com> - 2.15.1-6
- abrt-journal: First seek the journal tail and then set filters
- Resolves: rhbz#2128662
* Wed Oct 12 2022 Michal Srb <michal@redhat.com> - 2.15.1-5
- abrt-journal: call sd_journal_get_fd() right after sd_journal_open()
- Resolves: rhbz#2128662