journal: set flushed flag even if we fail to open runtime journals
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 5 Aug 2024 05:18:21 +0000 (14:18 +0900)
committerLuca Boccassi <bluca@debian.org>
Thu, 15 Aug 2024 13:04:41 +0000 (14:04 +0100)
As at this stage, a persistent journal file has been already opened, and
saved seqnum has been reset, and any later journal entries will be stored
to the file. Hence we should not open the runtime journal file by
server_system_journal_open() again.

(cherry picked from commit b55027efe41b266df4c4704e924fff7dfb32ad70)

src/journal/journald-server.c

index 717c8e480e5e042b40f81d1216f99ca9f71e2bc1..07748f00912c20c5689ca64cc7e84b53ccfb748b 100644 (file)
@@ -1349,9 +1349,10 @@ int server_flush_to_var(Server *s, bool require_flag_file) {
         start = now(CLOCK_MONOTONIC);
 
         r = sd_journal_open(&j, SD_JOURNAL_RUNTIME_ONLY | SD_JOURNAL_ASSUME_IMMUTABLE);
-        if (r < 0)
-                return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
-                                                 "Failed to read runtime journal: %m");
+        if (r < 0) {
+                log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to read runtime journal: %m");
+                goto finish;
+        }
 
         sd_journal_set_data_threshold(j, 0);