From: Luca Boccassi Date: Thu, 31 Jul 2025 12:23:59 +0000 (+0100) Subject: journald: add debug logs around offlining/archiving/rotating/varlink operations X-Git-Tag: v258-rc2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8cc1748ddcbccbe442761416f012da4d746afd3a;p=thirdparty%2Fsystemd.git journald: add debug logs around offlining/archiving/rotating/varlink operations It is not easy to understand what happens to a journal file even with debug logs enabled. Add more dbg messages around operations started by users to make it possible to follow the flow of operations. --- diff --git a/src/journal/journald-manager.c b/src/journal/journald-manager.c index f984c4a7cc0..54dd1f623e3 100644 --- a/src/journal/journald-manager.c +++ b/src/journal/journald-manager.c @@ -553,11 +553,14 @@ static int manager_do_rotate( int r; + assert(f); assert(m); if (!*f) return -EINVAL; + log_debug("Rotating journal file %s.", (*f)->path); + r = journal_file_rotate(f, m->mmap, manager_get_file_flags(m, seal), m->config.compress.threshold_bytes, m->deferred_closes); if (r < 0) { if (*f) diff --git a/src/journal/journald-varlink.c b/src/journal/journald-varlink.c index 81682ea8553..720c3628f1a 100644 --- a/src/journal/journald-varlink.c +++ b/src/journal/journald-varlink.c @@ -22,6 +22,8 @@ void sync_req_varlink_reply(SyncReq *req) { if (req->offline) manager_full_sync(req->manager, /* wait = */ true); + log_debug("Client request to sync journal (%s offlining) completed.", req->offline ? "with" : "without"); + /* Disconnect the SyncReq from the Varlink connection object, and free it */ _cleanup_(sd_varlink_unrefp) sd_varlink *vl = TAKE_PTR(req->link); sd_varlink_set_userdata(vl, req->manager); /* reinstall manager object */ @@ -96,6 +98,7 @@ static int vl_method_rotate(sd_varlink *link, sd_json_variant *parameters, sd_va log_info("Received client request to rotate journal, rotating."); manager_full_rotate(m); + log_debug("Client request to rotate journal completed."); return sd_varlink_reply(link, NULL); } @@ -119,6 +122,7 @@ static int vl_method_flush_to_var(sd_varlink *link, sd_json_variant *parameters, log_info("Received client request to flush runtime journal."); manager_full_flush(m); + log_debug("Client request to flush runtime journal completed."); return sd_varlink_reply(link, NULL); } @@ -142,6 +146,7 @@ static int vl_method_relinquish_var(sd_varlink *link, sd_json_variant *parameter log_info("Received client request to relinquish %s access.", m->system_storage.path); manager_relinquish_var(m); + log_debug("Client request to relinquish %s access completed.", m->system_storage.path); return sd_varlink_reply(link, NULL); } diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 2a08f923d11..c6ddac95986 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -197,10 +197,14 @@ int journal_file_set_offline_thread_join(JournalFile *f) { if (f->offline_state == OFFLINE_JOINED) return 0; + log_debug("Joining journal offlining thread for %s.", f->path); + r = pthread_join(f->offline_thread, NULL); if (r) return -r; + log_debug("Journal offlining thread for %s joined.", f->path); + f->offline_state = OFFLINE_JOINED; if (mmap_cache_fd_got_sigbus(f->cache_fd)) diff --git a/src/shared/journal-file-util.c b/src/shared/journal-file-util.c index 990146b6246..6591744c512 100644 --- a/src/shared/journal-file-util.c +++ b/src/shared/journal-file-util.c @@ -12,7 +12,9 @@ #include "fd-util.h" #include "journal-authenticate.h" #include "journal-file-util.h" +#include "journal-internal.h" #include "log.h" +#include "log-ratelimit.h" #include "set.h" #include "string-util.h" @@ -318,12 +320,25 @@ int journal_file_set_offline(JournalFile *f, bool wait) { target_state = f->archive ? STATE_ARCHIVED : STATE_OFFLINE; + log_ratelimit_full(LOG_DEBUG, + JOURNAL_LOG_RATELIMIT, + "Journal file %s is %s transitioning to %s.", + f->path, + wait ? "synchronously" : "asynchronously", + f->archive ? "archived" : "offline"); + /* An offlining journal is implicitly online and may modify f->header->state, * we must also join any potentially lingering offline thread when already in * the desired offline state. */ - if (!journal_file_is_offlining(f) && f->header->state == target_state) + if (!journal_file_is_offlining(f) && f->header->state == target_state) { + log_ratelimit_full(LOG_DEBUG, + JOURNAL_LOG_RATELIMIT, + "Journal file %s is already %s, waiting for offlining thread.", + f->path, + f->archive ? "archived" : "offline"); return journal_file_set_offline_thread_join(f); + } /* Restart an in-flight offline thread and wait if needed, or join a lingering done one. */ restarted = journal_file_set_offline_try_restart(f); @@ -336,6 +351,12 @@ int journal_file_set_offline(JournalFile *f, bool wait) { if (restarted) return 0; + log_ratelimit_full(LOG_DEBUG, + JOURNAL_LOG_RATELIMIT, + "Starting new %s offlining operation for journal file %s.", + wait ? "synchronous" : "asynchronous", + f->path); + /* Initiate a new offline. */ f->offline_state = OFFLINE_SYNCING;