contrib: Speed up systemd boot #26495

pull bubelov wants to merge 1 commits into bitcoin:master from bubelov:systemd-after-network changing 1 files +1 −2
  1. bubelov commented at 9:51 am on November 14, 2022: contributor

    Relevant issue: #26493

    The currently used pattern is supposed to help some super fragile programs which can crash or get stuck if they fail to execute some network requests. Bitcoin Core is far from being fragile so no one benefits from the current setup.

    It’s also possible to avoid adding any network hints to the unit file, but would prevent Bitcoin Core from closing the network connections gracefully on shutdown.

    Services using the network should hence simply place an After=network.target stanza in their unit files, without Wants=network.target or Requires=network.target.

    https://systemd.io/NETWORK_ONLINE/

    Adding After=network.target is beneficial for shutdown and it has no effect on the boot process, so I think it makes sense to replace the current network hooks with the less invasive and officially endorsed one.

  2. Speed up systemd boot 0e34096b93
  3. DrahtBot added the label Scripts and tools on Nov 14, 2022
  4. luke-jr commented at 11:38 pm on November 14, 2022: member

    Isn’t there a risk this triggers unnecessary DNS seed lookups and/or fallback to fixed seeds?

    Maybe we should see if there’s a way to get a signal from network-online to start the “peers db isn’t working out” timers?

  5. bubelov commented at 11:52 am on November 15, 2022: contributor

    Isn’t there a risk this triggers unnecessary DNS seed lookups and/or fallback to fixed seeds?

    I’m not sure how Bitcoin Core handles that. That systemd page is quite verbose and it discourages the use of network-online target in many places, for many reasons. Here is the approach they endorse the most:

    0Watch rtnetlink and react to network configuration changes as they happen. This is usually the nicest solution, but not always the easiest.
    

    There is also quite a tirade on “what does it mean to be online” there, implying that network-online isn’t really reliable. I think that depending on the discouraged parts of some external init systems is a bit problematic, because there are no hard guarantees, and because things might change without Bitcoin Core being aware of it, exposing it to potential trouble.

    I also checked my RaspiBlitz config and it looks like it doesn’t use network-online, so we probably already have thousands of nodes using the proposed init template with no issues. The RaspiBlitz devs fetched the Bitcoin Core template a year ago, though: https://github.com/rootzoll/raspiblitz/issues/2826

    A few interesting quotes from systemd doc:

    network-online.target is a target that actively waits until the network is “up”, where the definition of “up” is defined by the network management software. Usually it indicates a configured, routable IP address of some kind.

    Reacting to local network configuration changes in daemon code is not particularly hard. In fact many well-known network-facing services running on Linux have been doing this for decades. A service written like this is robust, can be started at any time, and will always do the best of the circumstances it is running in.

    A robust system boots up independently of external services. More specifically, if a network DHCP server does not react, this should not slow down boot on most setups, but only for those where network connectivity is strictly needed (for example, because the host actually boots from the network).

  6. hebasto commented at 11:46 am on November 25, 2022: member
    Could this change re-introduce errors like that?
  7. DrahtBot commented at 11:46 am on November 25, 2022: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  8. in contrib/init/bitcoind.service:17 in 0e34096b93
    13@@ -14,8 +14,7 @@ Description=Bitcoin daemon
    14 Documentation=https://github.com/bitcoin/bitcoin/blob/master/doc/init.md
    15 
    16 # https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
    17-After=network-online.target
    18-Wants=network-online.target
    19+After=network.target
    


    hebasto commented at 11:57 am on November 25, 2022:
    If this change finds reviewers’ support, isn’t cleaner to just revert d9392b724cae53b7a16fa5f84ebe152eea496502?
  9. fanquake commented at 10:10 am on February 8, 2023: member
    It’s unclear what the next steps are here, given the discussion in #26493, and the fact that other projects have moved to using network-online.target (https://github.com/fort-nix/nix-bitcoin/pull/567), to fix issues with bitcoind. Going to close this for now, and discussion can continue in #26493.
  10. fanquake closed this on Feb 8, 2023

  11. bitcoin locked this on Feb 8, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 13:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me