You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
During switchroot, devices transition plugged -> dead -> plugged #11997
systemd version the issue has been seen with
v240 and v241
Used distribution
Fedora
Unexpected behaviour you saw
With systemd 240 and 241, at switch root time, all devices change plugged -> dead -> plugged. (I tested fedora 29 + v239, v240, and v241, and it was a v239 -> v240 regression.)
Boot with systemd.log-level=debug printk.devkmsg=on log_buf_len=1M on the kernel command line
Search for plugged -> dead in the logs
Notes
With some poking and debug message insertion, I determined that the initial call to device_enumerate() after re-exec is not finding any devices - which is what I think is causing the problem - I couldn't easily find the cause in the v239 ... v240 diff.
(i mean, a don't really see why we would flush the udev db like we currently do. We trigger everything anyway thus making sure the new rules are in effect and its just extra worl to flush the db explicitly and it means we drop props and tags for a time during boot which creates this issue here.)
The only other option i see would be to freeze device unit states in pid1 while udev is not running and until all devices have been triggered and processed once. But that's always going to be awfully racy. And what happens with devices that actually really disappear during the transition? I mean, the user might actually pull a usb stick from the device right when we transition and that should definitely make the device unit in pid1 to go down
hmm, another idea might be to set the "db_persist" option on all devices in the initrd we consider relevant for systemd. it's frickin ugly though, but would make sure that once a device is relevant to systemd it stays so across the transition
So, yeah, I think the best approach for now would be to set "db_persist" on the select few devices where we really care and let's see if that makes things work.
I have the suspicion it would be a better fix to drop the initrd udev db cleanup service from the initrd. #otaylor, does that fix stuff for you?
I tried this - patching systemd to remove initrd-udevadm-cleanup-db.service - and:
I don't see any plugged -> dead messages
my system passes the 5-consecutive-boots test
my system seems functional in other ways on the surface
So, yeah, I think the best approach for now would be to set "db_persist" on the select few devices where we really care and let's see if that makes things work.
I don't have much of an idea how to go about coming up with such a patch or figuring out what devices "where we really care". Can test it if someone does.
@keszybz - do you have any opinions on this from a distro perspective? I think it would be great to have some fox for this in Fedora 30 - but it doesn't necessarily need to be the same fix as the long-term systemd fix. To my inexperienced eyes, dropping initrd-udevadm-cleanup-db.service would probably be pretty risky to do last minute compared to other options.
In the long run, I think #12148 is the most favorable way. Now many devices are initialized by udevd twice: in the initrd phase and after switching root. I guess most of the second initialization processes are redundant. Though, #12148 itself does not stop the double initialization. Also, I am not sure this is a good first step, i.e. before dropping initrd-udevadm-cleanup-db.service we may need to expose a flag whether a device is already initialized or not. Not sure.
I think #12013 is the safest way within the three PRs to fix this issue, as it just fixes a side effect introduced by 1fb70e6. But as already mentioned by @poettering, some devices may disappear during switching root and pid1 cannot detect that...
Activity
yuwata commentedon Mar 14, 2019
I think this is caused by 1fb70e6.
Before the commit,
device_catchup()does not emit state change (plugged -> dead).core: add Manager::honor_device_enumeration flag
yuwata commentedon Mar 15, 2019
I hope #12013 fixes this.
poettering commentedon Mar 26, 2019
I have the suspicion it would be a better fix to drop the initrd udev db cleanup service from the initrd. #otaylor, does that fix stuff for you?
poettering commentedon Mar 26, 2019
(i mean, a don't really see why we would flush the udev db like we currently do. We trigger everything anyway thus making sure the new rules are in effect and its just extra worl to flush the db explicitly and it means we drop props and tags for a time during boot which creates this issue here.)
poettering commentedon Mar 26, 2019
The only other option i see would be to freeze device unit states in pid1 while udev is not running and until all devices have been triggered and processed once. But that's always going to be awfully racy. And what happens with devices that actually really disappear during the transition? I mean, the user might actually pull a usb stick from the device right when we transition and that should definitely make the device unit in pid1 to go down
poettering commentedon Mar 26, 2019
hmm, another idea might be to set the "db_persist" option on all devices in the initrd we consider relevant for systemd. it's frickin ugly though, but would make sure that once a device is relevant to systemd it stays so across the transition
poettering commentedon Mar 26, 2019
So, yeah, I think the best approach for now would be to set "db_persist" on the select few devices where we really care and let's see if that makes things work.
owtaylor commentedon Mar 27, 2019
I tried this - patching systemd to remove
initrd-udevadm-cleanup-db.service- and:I don't have much of an idea how to go about coming up with such a patch or figuring out what devices "where we really care". Can test it if someone does.
@keszybz - do you have any opinions on this from a distro perspective? I think it would be great to have some fox for this in Fedora 30 - but it doesn't necessarily need to be the same fix as the long-term systemd fix. To my inexperienced eyes, dropping initrd-udevadm-cleanup-db.service would probably be pretty risky to do last minute compared to other options.
unit: drop initrd-udevadm-cleanup-db.service
yuwata commentedon Mar 29, 2019
I've created #12148 and #12149 based on the above @poettering's suggestions. PTAL.
yuwata commentedon Apr 1, 2019
So, there exist three fix for this issue: #12013, #12148 and #12149.
In the long run, I think #12148 is the most favorable way. Now many devices are initialized by
udevdtwice: in the initrd phase and after switching root. I guess most of the second initialization processes are redundant. Though, #12148 itself does not stop the double initialization. Also, I am not sure this is a good first step, i.e. before droppinginitrd-udevadm-cleanup-db.servicewe may need to expose a flag whether a device is already initialized or not. Not sure.I think #12013 is the safest way within the three PRs to fix this issue, as it just fixes a side effect introduced by 1fb70e6. But as already mentioned by @poettering, some devices may disappear during switching root and pid1 cannot detect that...
yuwata commentedon Jul 3, 2019
#12013 (comment) and https://bugzilla.suse.com/show_bug.cgi?id=1137373
yuwata commentedon Jul 4, 2019
#12013 (comment)
@fbuihuu Is the issue caused by this race condition?