[systemd-devel] journald on a system without real-time clock

Magnus Berglund wmmabeu at gmail.com
Mon Sep 21 08:16:38 UTC 2020


Hello,

I have an embedded system that does not have a real-time clock. I was
hoping to run journald on it, but have run into some problems.

My problem is that my system currently does not guarantee a monotonically
increasing time, and that seems to confuse journald a bit.

Btw: I've tested this on v243-stable.

(The system syncs over NTP, but there are some issues with this as well,
more on that later)

I originally found the problem since there were boots missing. E.g)

# journalctl --list-boots
-4 44cabeed86e34d09a4eca0dbff43b19f Mon 2020-08-03 14:27:59 UTC—Tue
2020-09-15 09:13:52 UTC
-3 71164e7d83a9448c9e70bb59b6190a45 Tue 2020-09-15 09:13:52 UTC—Tue
2020-09-15 09:14:48 UTC
-2 2e565a1c8dc84d4e95055e4cb4d0cc25 Tue 2020-09-15 09:14:48 UTC—Tue
2020-09-15 09:16:11 UTC
-1 3c672d6fb8084f5fa5923a1ae5e0e53d Tue 2020-09-15 09:16:11 UTC—Tue
2020-09-15 09:31:52 UTC
 0 afc0d98f275e4999aa061c7bb61b85d2 Tue 2020-09-15 09:33:35 UTC—Tue
2020-09-15 09:56:12 UTC

# journalctl -F _BOOT_ID
44cabeed86e34d09a4eca0dbff43b19f
71164e7d83a9448c9e70bb59b6190a45
1465a36c753f43df92bcc0a76d8e763e
2e565a1c8dc84d4e95055e4cb4d0cc25
3c672d6fb8084f5fa5923a1ae5e0e53d
afc0d98f275e4999aa061c7bb61b85d2
302cc41b146c4b3c88f06df102913c3f

I've poked around in the source code think I found the reason for
this: journal_file_compare_locations() (in journal-file.c) compares
seqnum if within the the same seqnum_id, but uses current_realtime if
not within the same seqnum_id. Since my realtime can't be trusted I
sometimes have journalfiles within the same seqnum_id which "jumps"
back in time. That combined with the traversal in real_journal_next()
gives a stochastic behaviour.

I have tried fixing my clock to give a monotonically increasing
clock. But: I want my system to boot as fast as possible, even without
a NTP-syncronized time. And I've noticed that if I shutdown before
getting a NTP time timesyncd will not have touched the "clock" file,
and I end up in the situation above.

Now to my question: What is the best practice in using journald on
systems without RTC? It it even "supported"?

/Regards,
Magnus Berglund
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20200921/0eec9677/attachment.htm>


More information about the systemd-devel mailing list