Skip to content

bug: Databend can't work with latest tokio #17797

Closed
@Xuanwo

Description

@Xuanwo

Search before asking

  • I had searched in the issues and found no similar issues.

Version

main

What's Wrong?

Our current usage of TcpStream is not allowed by latest tokio:

impl MySQLConnection {
pub fn run_on_stream(
session: Arc<Session>,
stream: TcpStream,
tls: Option<Arc<ServerConfig>>,
) -> Result<()> {
let blocking_stream = Self::convert_stream(stream)?;
MySQLConnection::attach_session(&session, &blocking_stream)?;
let non_blocking_stream = TcpStream::from_std(blocking_stream)?;

Also see tokio-rs/tokio#7172

panicked at src/query/service/src/servers/mysql/mysql_session.rs:53:35:
Registering a blocking socket with the tokio runtime is unsupported. If you wish to do anyways, please add `--cfg tokio_allow_from_blocking_fd` to your RUSTFLAGS. See github.com/tokio-rs/tokio/issues/7172 for details.
   0: backtrace::backtrace::trace
   1: databend_common_tracing::panic_hook::log_panic
   2: databend_common_tracing::panic_hook::set_panic_hook::{{closure}}
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic_handler::{{closure}}
   5: std::sys::backtrace::__rust_end_short_backtrace
   6: __rustc::rust_begin_unwind
   7: core::panicking::panic_fmt
   8: tokio::net::tcp::stream::TcpStream::from_std
   9: databend_query::servers::mysql::mysql_session::MySQLConnection::run_on_stream
  10: <databend_common_base::runtime::runtime_tracker::TrackingFuture<T> as core::future::future::Future>::poll
  11: std::thread::local::LocalKey<T>::with
  12: tokio::runtime::task::core::Core<T,S>::poll
  13: std::panic::catch_unwind
  14: tokio::runtime::task::harness::poll_future
  15: tokio::runtime::task::harness::Harness<T,S>::poll_inner
  16: tokio::runtime::task::harness::Harness<T,S>::poll
  17: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
  18: tokio::runtime::scheduler::multi_thread::worker::Context::run
  19: tokio::runtime::context::scoped::Scoped<T>::set
  20: tokio::runtime::context::runtime::enter_runtime
  21: tokio::runtime::scheduler::multi_thread::worker::run
  22: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
  23: tokio::runtime::task::core::Core<T,S>::poll
  24: std::panic::catch_unwind
  25: tokio::runtime::task::harness::poll_future
  26: tokio::runtime::task::harness::Harness<T,S>::poll_inner
  27: tokio::runtime::task::harness::Harness<T,S>::poll
  28: tokio::runtime::task::UnownedTask<S>::run
  29: tokio::runtime::blocking::pool::Inner::run
  30: std::sys::backtrace::__rust_begin_short_backtrace
  31: core::ops::function::FnOnce::call_once{{vtable.shim}}
  32: std::sys::pal::unix::thread::Thread::new::thread_start
  33: <unknown>
  34: <unknown>

How to Reproduce?

cargo build

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions