]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/journal/journald-server.h
journald: maintain entry seqnum counter in mmap()ed file in /run/
authorLennart Poettering <lennart@poettering.net>
Mon, 23 Jan 2023 20:21:21 +0000 (21:21 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 8 Feb 2023 12:42:29 +0000 (13:42 +0100)
commite5d60d1b3b0c0b229571823c7fdd390a9562982e
treef46db05768fb62e658f91562088ea01d438e6018
parent2bc70e2e9db13cfbc74e4bf1fd28ecbfef1466c9
journald: maintain entry seqnum counter in mmap()ed file in /run/

Let's ensure that entry seqnums remain stable and monotonic across the
entire runtime of the system, even if local storage is turned off. Let's
do this by maintainer a counter file in /run/ which we mmap() and
wherein we maintain the counter from early-boot on till late shutdown.

This takes inspiration of the kernel-seqnum file we already maintain
like that that tracks which kmsg messages we already processed. In fact,
we reuse the same code for maintaining it.

This should allow the behaviour entry seqnums to be more predictable, in
particular when journal local storage is turned off. Previously, we'd
maintain the seqnum simply by always bumping it to the maximum of the
last written entry seqnum plus one, and the biggest seqnum so far
written to the journal file on disk. If we'd never write a file on disk,
or if no journal file was existing during the initrd→seqnum transition
we'd completely lose the current seqnum position during daemon restarts
(such as the one happening during the switch-root operation).

This also will cause a journal file rotation whenever we try to write to
a journal file with multiple sequence number IDs, so that we know that
from early boot trhough the entire runtime we'll have stable sequence
numbers that do not jump, and thus can be used to determine "lost"
messages.
src/journal-remote/journal-remote-write.c
src/journal/journald-kmsg.c
src/journal/journald-server.c
src/journal/journald-server.h
src/journal/test-journal-flush.c
src/journal/test-journal-interleaving.c
src/journal/test-journal-stream.c
src/journal/test-journal-verify.c
src/journal/test-journal.c
src/libsystemd/sd-journal/journal-file.c
src/libsystemd/sd-journal/journal-file.h