Skip to content

[th/dbus-request-name-later] "RequestName" of NetworkManager D-Bus API later to fix race

Thomas Haller requested to merge th/dbus-request-name-later into main

NetworkManager.service is "Type=dbus". Systemd takes that as indication for declaring the service as started when the D-Bus name is acquired.

Currently, we acquire the name very early. The benefit is, that the service appears to start very fast. However, most the D-Bus API is not yet populated or ready to use. So if you order your service After=NetworkManager.service, then there is a race that NetworkManager might not yet be fully usable.

Another benefit was that requesting a D-Bus name is atomic. That means, we could take that to ensure only one NetworkManager daemon was running. If we noticed that NetworkManager is already running, we would quit without doing anything. In practice, systemd already ensures that the daemon is not running in parallel. This was still useful for catching misuse when testing manually. This is now no longer done. We will notice a concurrent NetworkManager only very late, at which point we might have already broken things (e.g. rewrite wrong state files).

Fix the race with After= by acquiring the name much later.


https://bugzilla.redhat.com/show_bug.cgi?id=2175919

Edited by Thomas Haller

Merge request reports