sd-journal: track newest open journal file per boot ID
authorLennart Poettering <lennart@poettering.net>
Wed, 8 Feb 2023 10:10:32 +0000 (11:10 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 2 Mar 2023 09:03:15 +0000 (10:03 +0100)
commit34af74946e8853411f18120007ebaca6549b2a52
tree9263446538e6e4a9777d9f7bf1366676b897d694
parent206f0f397edf1144c63a158fb30f496c3e89f256
sd-journal: track newest open journal file per boot ID

This is useful to later order boot IDs by time, addressing #662.

Basically, this determines the most recently written for each boot ID
from all currently open journal files. This is then stored in a hash
table (which maps the boot ID to a prioq of journal files, ordered by
their timestamp).

Why is this useful? If systems lack a battery-buffered RTC they will
initially have a system clock basically starting at zero. Later they
might acquire an NTP fix, or at least roughly monotonic time via a
stored timestamp. Thus, log entries written early during boot tend to be
badly timestamped, and those written most recently are likely to have
most accurate timestamps. Thus, if we track the newest entry for each
boot ID we likely can order the boot ID via their timestamps.

This commit only add the logic to maintain the hash table/prioq. It
doesn't actually make use of this information for ordering yet. A later
patch adds that.
src/libsystemd/sd-journal/journal-file.c
src/libsystemd/sd-journal/journal-file.h
src/libsystemd/sd-journal/journal-internal.h
src/libsystemd/sd-journal/sd-journal.c