[systemd-devel] generator logging during daemon-reload

Lennart Poettering lennart at poettering.net
Mon Nov 10 05:32:49 PST 2014


On Fri, 07.11.14 20:59, Alexandre Detiste (alexandre.detiste at gmail.com) wrote:

> Hi,
> 
> I know that generators should log to /dev/kmsg during early boot.

Correct!

> But, when they are restarted later by systemcl daemon-reload;
> is it better to write to the journal instead, by using systemd-cat for example ?
> Or is it racy/forbidden ?

Yes, this is dangerous. During a "daemon-reload" PID 1 serilizes its
state to a file in /run, then flushes all configuration, then invokes
the generators, and then rereads the configuration and deserializes
the state. Now, if you generator accesses the journal socket, and
journald is not running yet (because you are in emergency mode for
example), then things might deadlock: as logging is synchronous and
the socket buffer is limited in size your generator might block while
writing the log message and since activation cannot take place as PID
1 is not processing any events while doing the whole state
flush/config flush/generator magic/config reload/state reload it would
never unblock again.

Generators really really shouldn't talk to any other services, and
this means for logging they should log to /dev/kmsg or suchlike.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list