From 3c85d3fda50f71755aa276cfa60807c315bfc04b Mon Sep 17 00:00:00 2001 From: msizanoen Date: Fri, 24 Nov 2023 18:56:31 +0700 Subject: [PATCH] journald: reset runtime seqnum data when flushing to system journal Follow-up for e5d60d1b3b0c0b229571823c7fdd390a9562982e. The current system journal's seqnum ID will usually be different from the seqnum ID of the current runtime journal. Therefore, to avoid unnecessary rotations on boot, reset the runtime seqnum data when switching to system journal so that systemd-journald will adopt the system journal's seqnum ID and value on next write. Fixes #30092 --- src/journal/journald-server.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 1c3a2a0b37f..f2f52203677 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -42,6 +42,7 @@ #include "journald-stream.h" #include "journald-syslog.h" #include "log.h" +#include "memory-util.h" #include "missing_audit.h" #include "mkdir.h" #include "parse-util.h" @@ -1275,6 +1276,10 @@ int server_flush_to_var(Server *s, bool require_flag_file) { if (!s->system_journal) return 0; + /* Reset current seqnum data to avoid unnecessary rotation when switching to system journal. + * See issue #30092. */ + zero(*s->seqnum); + log_debug("Flushing to %s...", s->system_storage.path); start = now(CLOCK_MONOTONIC); -- 2.47.3