Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Drain all the pending messages in the channel when TracingUnboundedReceiver is dropped #13917

Merged
merged 1 commit into from
Apr 14, 2023

Conversation

NingLin-P
Copy link
Contributor

Fix #13849

tracing_unbounded uses async_channel internally, in which, the pending messages of the channel will not be dropped even if all the receivers have been dropped and these messages can never be accessed.

This may cause blocking issues when using tracing_unbounded to send Sender<T> and there is quite a lot of such usage within substrate as #13849 mentioned.

This PR fixes the issue by manually draining all the pending messages in the channel when TracingUnboundedReceiver is dropped and a test is added to cover the abovementioned case.

cc @bkchr

@bkchr
Copy link
Member

bkchr commented Apr 14, 2023

ty!

@bkchr bkchr added A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. B1-note_worthy Changes should be noted in the release notes T0-node This PR/Issue is related to the topic “node”. labels Apr 14, 2023
Copy link
Contributor

@dmitry-markin dmitry-markin left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@bkchr bkchr merged commit a9f67d0 into paritytech:master Apr 14, 2023
nathanwhit pushed a commit to nathanwhit/substrate that referenced this pull request Jul 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B1-note_worthy Changes should be noted in the release notes C1-low PR touches the given topic and has a low impact on builders. T0-node This PR/Issue is related to the topic “node”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential blocking issue when use tracing_unbounded channel to send Sender<T>
3 participants