Summary: | systemd-journal sometimes loses _CMDLINE, _COMM, _EXE, _SYSTEMD_CGROUP, _SYSTEMD_UNIT | ||
---|---|---|---|
Product: | systemd | Reporter: | Maksim Melnikau <maxposedon> |
Component: | general | Assignee: | Lennart Poettering <lennart> |
Status: | RESOLVED MOVED | QA Contact: | |
Severity: | critical | ||
Priority: | medium | CC: | bevan, crrodriguez, freedesktop, jeff, rektide |
Version: | unspecified | ||
Hardware: | x86-64 (AMD64) | ||
OS: | Linux (All) | ||
Whiteboard: | kernel-bug | ||
i915 platform: | i915 features: |
Description
Maksim Melnikau
2012-05-21 11:26:52 UTC
This is a race. We get the client PID with SCM_CREDENTIALS and then try to read _CMDLINE/_COMM/_EXEC and the cgroupd ata from /proc quickly but at that time the process might already have died. To fix this properly we need SCM_COMM or so, to get the process cmdline/comm/exe, and SCM_CGROUPS to get the cgroup data in a race free fashion. Until this is added to the kernel this will continue to be racy. These items are listed on the plumbers wishlist, because we need this from the kernel folks. Is some nice workaround exists? E.g. as I understand now program should do smth like "sleep 1", atexit, which is not very nice. May be should be added some call to ensure that data is logged. On some runner, which keeps process as ZOMBIE until all data is logged. I've noticed that often times- for example- `systemctl status keystone.service` might show a fail but have very minimal output, but `journalctl _SYSTEMD_UNIT=keystone.service` has all the output. This discrepancy doesn't wash well with me. If systemctl for whatever reason cannot do this itself, ought it not rely on whatever underpins journalctl? Asked in #systemd, was pointed at this bug. (In reply to Lennart Poettering from comment #1) > To fix this properly we need SCM_COMM or so, to get the process > cmdline/comm/exe, and SCM_CGROUPS to get the cgroup data in a race free > fashion. Until this is added to the kernel this will continue to be racy. can something be done about this in the interim? if systemd or journald knows that a program has exited without collecting some information, insert a sentinel into the journal that it has happened (which systemctl status could use), and maybe an informational 'xxx might be incomplete, use journalctl _EXE' or similar to facilitate people looking for information without asking for assistance and only being told there's basically a bug and to keep it in mind Why not have systemd-journald ask systemd for the process metadata needed to add the required fields to the journal? Have systemd maintain a cache of process metadata so that even if a process dies before a journal message is processed, systemd can still supply systemd-journald with the necessary data. IMO this would also be a better separation of concerns: have systemd manage process metadata which is to end up in fields such as _SYSTEMD_CGROUP, _SYSTEMD_SESSION, etc., and have systemd-journald take care only of maintaining the journal, adding fields such as PRIORITY, MESSAGE, etc. We can cache all we want, but that doesn't help at all for very short-lived processes. If a process is created, logs something and immediately exits, then we have the message and its PID but cannot use the PID anymore to retriev metainformation about it. journald can't and systemd can't either. The right fix is to get cgroup metadata sent along in the message. There where even kernel patches to add that, but the submitter dropped the ball unfortunately. There's a related pull request which improves the logging-just-before-exit problem by caching the metadata available for review and comment: https://github.com/systemd/systemd/pull/2280 It doesn't address the case of super-short-lived processes that start, log and exit, but it narrows the scope of the problem. There's an issue about this one also on github, let's continue this there, and close this one: https://github.com/systemd/systemd/issues/2913 |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.