-
Notifications
You must be signed in to change notification settings - Fork 42
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
refactor(filter): unsubscribe waitgroup, execute async, and guard against calling funtions while the protocol is not started #692
Conversation
Jenkins BuildsClick to see older builds (62)
|
912b4c9
to
32e051e
Compare
@chaitanyaprem, @harsh-98 if this pattern looks fine, in future PRs i'll add the same logic to other protocols that could run into the same issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I would maybe add some tests to verify the behavior?
7f3763a
to
d64a04f
Compare
Added some tests to verify behaviour! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from minor comments.
Yup, makes sense. |
@richard-ramos with regards of the race condition between https://github.com/waku-org/go-waku/compare/async-filter-wg-test?expand=1
That would happen if you call
You can replicate using the command:
and you can check for detected race conditions using
The issue is that Probably worth discussing how to address in the call, locks are obviously a solution, but we need to make sure we don't deadlock, but we can discuss later. |
🤔 interesting. We do use CompareAndSwap in discv5, so I wonder if this scenario could happen there too. |
14b5766
to
ae0f000
Compare
@cammellos with latest commit, I copied your test and replaced the instances of CompareAndSwap in filter client and it is not panicking anymore! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great @richard-ramos , thank you!
1c82a01
to
9d648cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
A comment regarding probable impact on performance due to this lock.
9d648cc
to
b1acd53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
In #691 it was reported that in status-go, go-waku fails when unsubscribing from a filter full node. Looking at the different scenarios where this could happen, it seems that this could be caused due to a race condition between calling Unsubscribe and stopping the node. This s because in status-go, ideally the logout from an account should be fast, and it cannot wait for confirmations that the unsubscription was successful.
To avoid such scenarios, and keep the API unaffected, this PR introduces new options to allow executing the unsubscribe functions in a fire and forget fashion, to optionally allow specifying a Waitgroup, as well as adding some guard conditions to return an error if the filter client has not been started
Issue
Part of #634