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

rpc: fix subscribers locking logic and properly drain poll-based waiter receiver #2804

Merged
merged 6 commits into from
Nov 16, 2022

Conversation

AnnaShaleva
Copy link
Member

Close #2775.

@roman-khimov, it's a bingo...

Follow the other errors formatting style.
Make it more detailed for better debugging experience.
If it's a subscription for AERs, we need to check the filter's state only
if it has been provided, otherwise filter is always valid.
@AnnaShaleva AnnaShaleva added the bug Something isn't working label Nov 16, 2022
@AnnaShaleva AnnaShaleva added the rpc RPC server and client label Nov 16, 2022
@AnnaShaleva AnnaShaleva added this to the v0.99.6 milestone Nov 16, 2022
// We can easily end up in a situation when subscription was performed too late and
// the desired transaction and VUB-th block have already got accepted before the
// subscription happened. Thus, always retry with non-ws client, it will perform
// AER requests and make sure.
Copy link
Member

Choose a reason for hiding this comment

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

Subscribe first, send afterwards? We need some issue for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

See #2805.

@AnnaShaleva
Copy link
Member Author

There still some deadlock either in TestWSClient_Wait or in the implementation itself, I'm keeping investigation.

@AnnaShaleva
Copy link
Member Author

Found it, we need to rework the logic of (w *EventWaiter) WaitAny.

Do not block subscribers until the unsubscription request to RPC server
is completed. Otherwise, another notification may be received from the
RPC server which will block the unsubscription process.

At the same time, fix event-based waiter. We must not block the receiver
channel during unsubscription because there's a chance that subsequent
event will be sent by the server. We need to read this event in order not
to block the WSClient's readloop.
If VUB-th block is received, we still can't guaranty that transaction
wasn't accepted to chain. Back this situation by rolling back to a
poll-based waiter.
@AnnaShaleva AnnaShaleva force-pushed the check-aer-sub branch 2 times, most recently from 54336cf to 3588ad5 Compare November 16, 2022 20:52
Avoid receiver channels locks.
@AnnaShaleva
Copy link
Member Author

OK, it should work properly now, the test is also fixed.

@codecov
Copy link

codecov bot commented Nov 16, 2022

Codecov Report

Merging #2804 (1399496) into master (bd67fe5) will increase coverage by 0.01%.
The diff coverage is 64.91%.

@@            Coverage Diff             @@
##           master    #2804      +/-   ##
==========================================
+ Coverage   84.75%   84.77%   +0.01%     
==========================================
  Files         327      327              
  Lines       41368    41390      +22     
==========================================
+ Hits        35062    35088      +26     
+ Misses       4876     4869       -7     
- Partials     1430     1433       +3     
Impacted Files Coverage Δ
pkg/rpcclient/actor/waiter.go 63.44% <61.62%> (+10.14%) ⬆️
pkg/rpcclient/wsclient.go 62.89% <70.83%> (+0.93%) ⬆️
pkg/neotest/basic.go 94.07% <100.00%> (+0.02%) ⬆️
pkg/services/rpcsrv/server.go 77.20% <100.00%> (ø)
pkg/vm/stackitem/serialization.go 91.02% <0.00%> (-1.29%) ⬇️
pkg/core/blockchain.go 79.57% <0.00%> (-0.24%) ⬇️
pkg/core/native/management.go 92.20% <0.00%> (-0.11%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

The main thing for now is that it fixes #2775. Waiter has a bit more chances now too.

@roman-khimov roman-khimov merged commit ab0ff63 into master Nov 16, 2022
@roman-khimov roman-khimov deleted the check-aer-sub branch November 16, 2022 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rpc RPC server and client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subscribe filtering issue
2 participants