I am trying to use tokio::sync::mpsc::channel
for communication between Repository and Controller. However, after a few message change, sender is blocked on the .send
because the buffer is full and the receiver reads 2 more messages after that and waits for a new message. The problem is that the sender doesn’t get unblocked so they both are hanging.
Additionally, sometimes the sender is crashed with the error message:
called Result::unwrap() on an Err value: SendError { .. }
stack backtrace:
0: 0x5ee725995085 - std::backtrace_rs::backtrace::libunwind::trace::h1a07e5dba0da0cd2
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
1: 0x5ee725995085 - std::backtrace_rs::backtrace::trace_unsynchronized::h61b9b8394328c0bc
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x5ee725995085 - std::sys_common::backtrace::_print_fmt::h1c5e18b460934cff
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:68:5
3: 0x5ee725995085 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1e1a1972118942ad
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:44:22
4: 0x5ee7259c463b - core::fmt::rt::Argument::fmt::h07af2b4071d536cd
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/rt.rs:165:63
5: 0x5ee7259c463b - core::fmt::write::hc090a2ffd6b28c4a
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/mod.rs:1157:21
6: 0x5ee725990e0f - std::io::Write::write_fmt::h8898bac6ff039a23
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/mod.rs:1832:15
7: 0x5ee725994e5e - std::sys_common::backtrace::_print::h4e80c5803d4ee35b
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:47:5
8: 0x5ee725994e5e - std::sys_common::backtrace::print::ha96650907276675e
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:34:9
9: 0x5ee7259962c9 - std::panicking::default_hook::{{closure}}::h215c2a0a8346e0e0
10: 0x5ee72599600d - std::panicking::default_hook::h207342be97478370
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:298:9
11: 0x5ee725996773 - std::panicking::rust_panic_with_hook::hac8bdceee1e4fe2c
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:795:13
12: 0x5ee725996654 - std::panicking::begin_panic_handler::{{closure}}::h00d785e82757ce3c
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:664:13
13: 0x5ee725995549 - std::sys_common::backtrace::__rust_end_short_backtrace::h1628d957bcd06996
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:171:18
14: 0x5ee725996387 - rust_begin_unwind
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
15: 0x5ee721e10e23 - core::panicking::panic_fmt::hdc63834ffaaefae5
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
16: 0x5ee721e113b6 - core::result::unwrap_failed::h82b551e0ff2b2176
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/result.rs:1654:5
17: 0x5ee72351a174 - test_lib::mvc::repositories::diagnostics_repository::DiagnosticsRepository::new::{{closure}}::hefffb3e0d8c01266
18: 0x5ee723624c7c - tokio::runtime::task::core::Core<T,S>::poll::{{closure}}::h6ca9c3cc94266151
19: 0x5ee723623d26 - tokio::runtime::task::core::Core<T,S>::poll::h389b29bb2da4ef41
20: 0x5ee7235a354e - tokio::runtime::task::harness::poll_future::{{closure}}::haf6ce93639b811b4
21: 0x5ee72342d6a1 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h9451889235d6d437
22: 0x5ee7234b69a5 - std::panicking::try::do_call::h42eda67a25deb7d1
23: 0x5ee7234bc91b - __rust_try
24: 0x5ee7234b60e8 - std::panicking::try::he6eb0d217f6833cc
25: 0x5ee72344f06e - std::panic::catch_unwind::h726bd10df4b7bb23
26: 0x5ee7235a0328 - tokio::runtime::task::harness::poll_future::h659fadf27d3cd68f
27: 0x5ee7235a5296 - tokio::runtime::task::harness::Harness<T,S>::poll_inner::hc8681162e26daac9
28: 0x5ee7235a8697 - tokio::runtime::task::harness::Harness<T,S>::poll::hcf02e0ccc8651f4c
29: 0x5ee7235cf5a0 - tokio::runtime::task::raw::poll::h9a1327d24de06ec8
30: 0x5ee72585053b - tokio::runtime::task::raw::RawTask::poll::hb35a303356eb4002
31: 0x5ee7257d7a65 - tokio::runtime::task::LocalNotified<S>::run::he5eb92f0d0c307d6
32: 0x5ee725838c97 - tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}::h201e051fb1c5ec66
33: 0x5ee7258384c6 - tokio::runtime::scheduler::multi_thread::worker::Context::run_task::hb80836cb819ae1e8
34: 0x5ee725837b81 - tokio::runtime::scheduler::multi_thread::worker::Context::run::hb91c6941ce403be4
35: 0x5ee7258377e4 - tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}::hf988b1cba975658b
36: 0x5ee725802b0f - tokio::runtime::context::scoped::Scoped<T>::set::h8f99195fc9de4eb1
37: 0x5ee7257f1331 - tokio::runtime::context::set_scheduler::{{closure}}::h67d1c868712f9134
38: 0x5ee725807d66 - std::thread::local::LocalKey<T>::try_with::h63a439d6184a893c
39: 0x5ee725807407 - std::thread::local::LocalKey<T>::with::h0fc418520ca33407
40: 0x5ee7257f1302 - tokio::runtime::context::set_scheduler::h701c78301719ad17
41: 0x5ee7258376ee - tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::h3a01f124215459ac
42: 0x5ee7257fa2f0 - tokio::runtime::context::runtime::enter_runtime::h62c1f6e614dab63f
43: 0x5ee72583747e - tokio::runtime::scheduler::multi_thread::worker::run::h2164734c692a6bc6
44: 0x5ee7258372f7 - tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}::hb8c1de657a449794
45: 0x5ee725806b94 - <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll::he5624d72ff51a125
46: 0x5ee725817d5c - tokio::runtime::task::core::Core<T,S>::poll::{{closure}}::h9ee6e2fff07ffbbc
47: 0x5ee7258178d6 - tokio::runtime::task::core::Core<T,S>::poll::hf0a5e2f32e5e5b8e
48: 0x5ee7257c881e - tokio::runtime::task::harness::poll_future::{{closure}}::h51cd518026e1254a
49: 0x5ee7257f34b1 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h3dcbc6ede734371b
50: 0x5ee725846e45 - std::panicking::try::do_call::h9a0cec4c693d2a78
51: 0x5ee72584827b - __rust_try
52: 0x5ee725846ae8 - std::panicking::try::hf73d7ce5010e335d
53: 0x5ee7257d26de - std::panic::catch_unwind::h9f0295dd218b4f2d
54: 0x5ee7257c7578 - tokio::runtime::task::harness::poll_future::h0225539cc68e1ac2
55: 0x5ee7257c4c86 - tokio::runtime::task::harness::Harness<T,S>::poll_inner::h22ebd2b6e3c8854a
56: 0x5ee7257c4847 - tokio::runtime::task::harness::Harness<T,S>::poll::h8421a139d5fb73ef
57: 0x5ee725850770 - tokio::runtime::task::raw::poll::h9958626120a47924
58: 0x5ee72585053b - tokio::runtime::task::raw::RawTask::poll::hb35a303356eb4002
59: 0x5ee7257d7b1d - tokio::runtime::task::UnownedTask<S>::run::h45f5faa2e6fcd1f5
60: 0x5ee7257e1ab6 - tokio::runtime::blocking::pool::Task::run::h6a5f59bf7643ea59
61: 0x5ee7257e534e - tokio::runtime::blocking::pool::Inner::run::h39a31935dad81904
62: 0x5ee7257e5084 - tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}::h2f211685772c9218
63: 0x5ee7257d1f66 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd0c3b4dc6be763fd
64: 0x5ee7257f4d42 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h717cf1b4313e2d64
65: 0x5ee7257f3512 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h4ec981d85cee1ea6
66: 0x5ee725847032 - std::panicking::try::do_call::hd32ec965e2468180
67: 0x5ee72584827b - __rust_try
68: 0x5ee725845f37 - std::panicking::try::h48b03b01d45c2d1f
69: 0x5ee7257f48e6 - std::thread::Builder::spawn_unchecked_::{{closure}}::h206982e4d2b7721d
70: 0x5ee7257fb887 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h4f977d10b1f27ace
71: 0x5ee72599bc2b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h09e5a4c541afa800
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
72: 0x5ee72599bc2b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9c8b03c22f4e7026
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
73: 0x5ee72599bc2b - std::sys::pal::unix::thread::Thread::new::thread_start::h522bc89a54da820a
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys/pal/unix/thread.rs:108:17
74: 0x7c53f589ca94 - start_thread
at ./nptl/pthread_create.c:447:8
75: 0x7c53f5929c3c - __GI___clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
76: 0x0 - <unknown>```