You are not logged in.

#1 2025-05-09 20:28:34

crashandburn4
Member
Registered: 2013-03-03
Posts: 108

[Solved] How can I track down a systemd Before directive.

I am debugging my boot time, and it seems that 

postgresql.service

is depended on by my

multi-user.target

(which requires my network to have started up. There's another issue that I'm going to try and dig into after, but this is the first one).

$ systemd-analyze critical-chain
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.

graphical.target @18.237s
└─multi-user.target @18.237s
  └─postgresql.service @17.431s +190ms
    └─network-online.target @17.430s
      └─NetworkManager-wait-online.service @12.012s +5.417s
        └─NetworkManager.service @10.681s +1.327s
          └─basic.target @10.676s
            └─dbus-broker.service @10.640s +29ms
              └─dbus.socket @10.613s
                └─sysinit.target @10.602s
                  └─systemd-udev-settle.service @515ms +10.087s
                    └─systemd-udev-trigger.service @416ms +77ms
                      └─systemd-udevd-kernel.socket @396ms
                        └─system.slice
                          └─-.slice

Alright... so why does that happen?

$ systemctl cat postgresql.service | grep multi-user
WantedBy=multi-user.target

Well... that's a WantedBy. That shouldn't block. nothing suspicious in

multi-user.target

either.

I went looking for rogue drop-in files or something. but can't find anything. it definitely seems like the

Before

is there though:

$ systemctl show postgresql.service --property=Requires,After,Before,Wants,WantedBy | cat
Requires=sysinit.target system.slice -.mount
Wants=network-online.target tmp.mount -.mount
WantedBy=multi-user.target
Before=shutdown.target multi-user.target
After=systemd-journald.socket sysinit.target network-online.target basic.target network.target tmp.mount system.slice -.mount systemd-tmpfiles-setup.service

So... how do I figure out where this has come from? I've tried randomly grepping everywhere... and looking for symlinks with

grep -r "postgresql" /etc/systemd/system /usr/lib/systemd/system

and

find

in the same directories, but only found the

postgresql.service

and the wants symlink (which is expected).

I can't find anything else, or any reason for this

Before

relationship.

What can I do to debug this and figure out why my mult-user.target waits for my postgresql to start?

Last edited by crashandburn4 (2025-05-10 22:47:54)

Offline

#2 2025-05-09 22:56:40

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 352

Re: [Solved] How can I track down a systemd Before directive.

crashandburn4 wrote:

What can I do to debug this and figure out why my mult-user.target waits for my postgresql to start?

"Before=multi-user.target" for postgresql.service is equal to "After=postgresql.service" for multi-user.target.

"After=postgresql.service" is set for multi-user.target because of:

Target units will automatically complement all configured dependencies of type Wants= or Requires= with dependencies of type After= unless DefaultDependencies=no is set in the specified units.

(systemd.target)

"Wants=postgresql.service" for multi-user.target is set because postgresql.service unit has

[Install]
WantedBy=multi-user.target

and the service is enabled.

Offline

#3 2025-05-10 22:47:17

crashandburn4
Member
Registered: 2013-03-03
Posts: 108

Re: [Solved] How can I track down a systemd Before directive.

Thank you! doing some reading I think you're right.

Offline

Board footer

Powered by FluxBB