Repository navigation
systemd: fix jitter in dbus connection retry backoff - #85
Merged
Merged
Conversation
kolyshkin
approved these changes
Oct 7, 2026
kolyshkin
left a comment
Contributor
There was a problem hiding this comment.
LGTM
Can you add
Fixes: cd71e92 ("systemd: retry when the dbus connection returns EAGAIN")
footer?
thaJeztah
approved these changes
Oct 7, 2026
thaJeztah
left a comment
Member
There was a problem hiding this comment.
LGTM
@kolyshkin didn't merge yet because your comment w.r.t. the commit footer, but good to go otherwise?
hakman
force-pushed
the
systemd-dbus-retry-jitter
branch
2 times, most recently
from
October 8, 2026 06:50
4b7ca11 to
7c53df9
Compare
Contributor
Author
|
Added the footer as requested. Thank you both for the review. |
Member
|
GPG signature seems invalid
|
The jitter added to the backoff delay in newConnection is computed in milliseconds and then converted to time.Duration as is, which makes it nanoseconds: at most 800 ns, rather than the ~12.5% of the delay the comment above promises. As a result, clients refused at the same time retry at the same time. Fix this by making the jitter 0 to 1/8 of the delay, as intended. Fixes: cd71e92 ("systemd: retry when the dbus connection returns EAGAIN") Signed-off-by: Ciprian Hacman <ciprian@hakman.dev>
hakman
force-pushed
the
systemd-dbus-retry-jitter
branch
from
October 8, 2026 08:20
7c53df9 to
ac3fe77
Compare
Contributor
Author
Thanks for catching this @AkihiroSuda, fixed now. |
AkihiroSuda
approved these changes
Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
newConnection()retries with exponential backoff when connecting to dbus fails withEAGAIN(#45). The comment says100ms * 2^attempt + ~12.5% jitter, but the jitter is computed in milliseconds and then converted totime.Durationas is, which makes it nanoseconds:For the first attempt
delay.Milliseconds() >> 3is12, so the jitter istime.Duration(rand.Int64N(13)), i.e. 0 to 12 nanoseconds. On the last attempt it is at most 800 ns. In effect there is no jitter: clients refused at the same moment retry at the same moment, on every attempt.This PR makes the jitter 0 to 1/8 of the delay, as the comment intends.
rand.Nis generic over integer types and takes atime.Durationdirectly (doc):Verifying
Maximum jitter per attempt before and after. This is deterministic, so it can be checked by running the following code:
Effect under load
Measured with 750 clients connecting at once to a
dbus-daemonalready at its per-user connection limit (Ubuntu 26.04, dbus-daemon 1.16.2, the 7 attempts from the code):