]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: reset runtime seqnum data when flushing to system journal
authormsizanoen <msizanoen@qtmlabs.xyz>
Fri, 24 Nov 2023 11:56:31 +0000 (18:56 +0700)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 4 Dec 2023 06:14:25 +0000 (15:14 +0900)
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

index 1c3a2a0b37f9ad7fc7e66fcd0214d3eb6fe8eb88..f2f5220367778071bf10f6d6003c0ce05598d443 100644 (file)
@@ -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);