Skip to content
New issue

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

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

Already on GitHub? # to your account

Bug fix waiting for non completing tasks to return #63

Merged
merged 1 commit into from
Aug 12, 2021

Conversation

ogenev
Copy link
Member

@ogenev ogenev commented Aug 7, 2021

I was unsuccessfully trying to connect trin-state with ddht using this guide.
After some debugging with netcat, the sockets and udp ports looked fine. Then I started to look into the code and realized that tokio;;join! is waiting for process_discv5_requests and process_jsonrpc_requests to complete before executing p2p.ping_bootnodes().await.unwrap();.

I'm new to tokio, but I think this is probably the simplest fix for now.

Copy link
Member

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

The changes look good :)

@mrferris
Copy link
Collaborator

mrferris commented Aug 8, 2021

This change also looks good to me. I don't see how the bootnode pinging could have been reached without your change.

If my git blame analysis is correct, it looks like it used to used spawn but @njgheorghita switched it to use join. Nick, any thoughts we haven't considered on this change?

@SamWilsn
Copy link
Collaborator

SamWilsn commented Aug 8, 2021

From a quick glance, this should probably be two spawns (to run the tasks in the background) and a select (to exit as soon as the first task exits) instead of a join.

@njgheorghita
Copy link
Collaborator

Yup this checks out with me, can't remember exactly why I switched it to join, but seems like it wasn't the right move.

@ogenev
Copy link
Member Author

ogenev commented Aug 11, 2021

From a quick glance, this should probably be two spawns (to run the tasks in the background) and a select (to exit as soon as the first task exits) instead of a join.

I don't understand why we need tokio::select!, I guess we don't expect any of the tasks to exit?

@SamWilsn
Copy link
Collaborator

I don't understand why we need tokio::select!, I guess we don't expect any of the tasks to exit?

I don't think we strictly need select, but if either task panics, we probably want the whole application to exit (or possibly restart the task, or log, etc.)

@ogenev
Copy link
Member Author

ogenev commented Aug 12, 2021

I don't think we strictly need select, but if either task panics, we probably want the whole application to exit (or possibly restart the task, or log, etc.)

This totally makes sense. I'm thinking of merging the PR as it is for now, because I'm not sure if we should dive into proper error handling at this time....

@mrferris mrferris merged commit bb7bd9e into master Aug 12, 2021
@ogenev ogenev deleted the bug-fix-ping-bootnodes branch August 27, 2021 09:30
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants