Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid a deadlock updating the network D-Bus tree #966

Merged
merged 2 commits into from Dec 29, 2023

Conversation

imobachgs
Copy link
Member

@imobachgs imobachgs commented Dec 29, 2023

Problem

If the network service receives an Apply at the same time as any other request, it may get blocked.

Solution

Updating the tree must be done in a separate task. Otherwise, it could fight with an incoming request for the ObjectServer mutex, blocking the actions dispatching.

Using tokio-console

I decided to use tokio-console to make it easier to find the problem. This tool collects and displays information about the asynchronous tasks in your program. In the screenshot below you can see that the D-Bus Set dispatchers are blocked.

Captura desde 2023-12-29 10-52-45

Once you find the problem, it is kind of "obvious", but it may take some time until you figure out what is happening.

To use tokio-console you need to add some instrumentation to your program and, at this point, it implies adding some unstable Tokio APIs. So if you want to give it a try, you can try the code in the tokio-console branch.

Updating the tree must be done in a separate task. Otherwise, it could
fight with an incoming request for the ObjectServer mutex, blocking the
actions dispatching.
@coveralls
Copy link

coveralls commented Dec 29, 2023

Coverage Status

coverage: 74.997% (-0.01%) from 75.009%
when pulling c40e251 on avoid-dbus-tree-deadlock
into e4ae7ed on master.

Copy link
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better now ;)

@imobachgs imobachgs merged commit d9b0131 into master Dec 29, 2023
2 checks passed
@imobachgs imobachgs deleted the avoid-dbus-tree-deadlock branch December 29, 2023 13:03
@imobachgs imobachgs mentioned this pull request Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants