-
Notifications
You must be signed in to change notification settings - Fork 690
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 v2: backpressure chainhead_v1_follow
#6058
Conversation
chainhead_follow_v1
chainhead_v1_follow
bot fmt |
@pkhry https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7571594 was started for your command Comment |
@pkhry Command |
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
where | ||
S: Stream<Item = T> + Unpin + Send + 'static, |
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.
ok nice catch :)
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.
IIRC, this was causing the lifetime issue Pavlo mentioned before, nice catch indeed :D
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
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! Thanks for handling this @pkhry 🙏
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com>
bot fmt |
@pkhry https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7598335 was started for your command Comment |
@pkhry Command |
I guess this PR could be backported to 2407 and 2409 as well, similar to #5741 👍🏻 cc @niklasad1 |
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-6058-to-stable2407
git worktree add --checkout .worktree/backport-6058-to-stable2407 backport-6058-to-stable2407
cd .worktree/backport-6058-to-stable2407
git reset --hard HEAD^
git cherry-pick -x a0aefc6b233ace0a82a8631d67b6854e6aeb014b
git push --force-with-lease |
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-6058-to-stable2409
git worktree add --checkout .worktree/backport-6058-to-stable2409 backport-6058-to-stable2409
cd .worktree/backport-6058-to-stable2409
git reset --hard HEAD^
git cherry-pick -x a0aefc6b233ace0a82a8631d67b6854e6aeb014b
git push --force-with-lease |
closes #5871 > The chainHead_v1_follow is using unbounded channels to send out messages on the JSON-RPC connection which may use lots of memory if the client is slow and can't really keep up with server i.e, substrate may keep lots of message in memory This PR changes the outgoing stream to abort and send a `Stop` event downstream in the case that client doesn't keep up with the producer. *In depth notes about how this PR should be integrated by downstream projects. This part is mandatory, and should be reviewed by reviewers, if the PR does NOT have the `R0-Silent` label. In case of a `R0-Silent`, it can be ignored.* - `rpc::Subscription::pipe_from_stream` - now takes `Self` param by reference, change was made to allow sending events to the `Subscription` after calls to `pipe_from_stream`. - `chainhead_follow::submit_events` - now uses `Abortable` stream to end it early in case - connection was closed by the client - signal received that subscription should stop - error has occured when processing the events - client can't keep up with the events produced - TODO: - make the abort logic less hacky --------- Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> (cherry picked from commit a0aefc6) Signed-off-by: Pavlo Khrystenko <p.khrystenko@gmail.com>
Description
closes #5871
This PR changes the outgoing stream to abort and send a
Stop
event downstream in the case that client doesn't keep up with the producer.Integration
In depth notes about how this PR should be integrated by downstream projects. This part is mandatory, and should be
reviewed by reviewers, if the PR does NOT have the
R0-Silent
label. In case of aR0-Silent
, it can be ignored.Review Notes
rpc::Subscription::pipe_from_stream
- now takesSelf
param by reference, change was made to allow sending events to theSubscription
after calls topipe_from_stream
.chainhead_follow::submit_events
- now usesAbortable
stream to end it early in case