databendlabs / databend

𝗗𝗮𝘁𝗮, 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 & 𝗔𝗜. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.75k stars 739 forks source link

mysql client command: status hang #5894

Closed wubx closed 2 years ago

wubx commented 2 years ago

Summary

MySQL [(none)]> status;
--------------
mysql  Ver 15.1 Distrib 10.7.3-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Connection id:          13
Current database:       default
Current user:           'root'@'127.0.0.1'
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server:                 MySQL
Server version:         8.0.26-v0.7.78-nightly-53edeb9-simd(rust-1.63.0-nightly-2022-06-09T16:23:20.473101143Z) 0
Protocol version:       10
Connection:             127.0.0.1 via TCP/IP
Server characterset:    0
Db     characterset:    0
Client characterset:    0
Conn.  characterset:    0
TCP port:               3307
^CCtrl-C -- exit!
Aborted
wu@fz001:~$ mysql -h 127.0.0.1 -P3307 -uroot 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.26-v0.7.78-nightly-53edeb9-simd(rust-1.63.0-nightly-2022-06-09T16:23:20.473101143Z) 0

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> select version();
+-----------------------------------------------------------------------------------------+
| @@version()                                                                             |
+-----------------------------------------------------------------------------------------+
| 8.0.26-v0.7.78-nightly-53edeb9-simd(rust-1.63.0-nightly-2022-06-09T16:23:20.473101143Z) |
+-----------------------------------------------------------------------------------------+
1 row in set (0.002 sec)
TCeason commented 2 years ago

Yes, I also find this question yesterday.

TCeason commented 2 years ago

Now we can sure: the pacic is here : opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs panic.file=".cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs" panic.line=454 panic.column=48

    async fn run(mut self) -> Result<(), B::Error> {
        use crate::commands::Command;

        let mut stmts: HashMap<u32, _> = HashMap::new();
        while let Some((seq, packet)) = self.reader.next_async().await? {
            self.writer.set_seq(seq + 1);
-->            let cmd = commands::parse(&packet).unwrap().1;

Error info:

Error(Error { input: [9], code: Tag })', /ubuntu/xx/.cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs:454:48 backtrace=Backtrace [{ fn: "common_tracing::panic_hook::log_panic", file: "./common/tracing/src/panic_hook.rs", line: 31 }, { fn: "common_tracing::panic_hook::set_panic_hook::{{closure}}", file: "./common/tracing/src/panic_hook.rs", line: 26 }, { fn: "std::panicking::rust_panic_with_hook", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 702 }, { fn: "std::panicking::begin_panic_handler::{{closure}}", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 588 }, { fn: "std::sys_common::backtrace::__rust_end_short_backtrace", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys_common/backtrace.rs", line: 138 }, { fn: "rust_begin_unwind", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 584 }, { fn: "core::panicking::panic_fmt", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panicking.rs", line: 142 }, { fn: "core::result::unwrap_failed", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/result.rs", line: 1785 }, { fn: "core::result::Result<T,E>::unwrap", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/result.rs", line: 1078 }, { fn: "opensrv_mysql::AsyncMysqlIntermediary<B,S>::run::{{closure}}", file: "/ubuntu/xx/.cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs", line: 454 }, { fn: "<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/future/mod.rs", line: 91 }, { fn: "opensrv_mysql::AsyncMysqlIntermediary<B,S>::run_with_options::{{closure}}", file: "/ubuntu/xx/.cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs", line: 250 }, { fn: "<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/future/mod.rs", line: 91 }, { fn: "databend_query::servers::mysql::mysql_session::MySQLConnection::run_on_stream::{{closure}}::{{closure}}", file: "./query/src/servers/mysql/mysql_session.rs", line: 52 }, { fn: "<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/future/mod.rs", line: 91 }, { fn: "tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/core.rs", line: 165 }, { fn: "tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/loom/std/unsafe_cell.rs", line: 14 }, { fn: "tokio::runtime::task::core::CoreStage<T>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/core.rs", line: 155 }, { fn: "tokio::runtime::task::harness::poll_future::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 470 }, { fn: "<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panic/unwind_safe.rs", line: 271 }, { fn: "std::panicking::try::do_call", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 492 }, { fn: "__rust_try" }, { fn: "std::panicking::try", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 456 }, { fn: "std::panic::catch_unwind", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panic.rs", line: 137 }, { fn: "tokio::runtime::task::harness::poll_future", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 458 }, { fn: "tokio::runtime::task::harness::Harness<T,S>::poll_inner", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 104 }, { fn: "tokio::runtime::task::harness::Harness<T,S>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 57 }, { fn: "tokio::runtime::task::raw::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/raw.rs", line: 144 }, { fn: "tokio::runtime::task::raw::RawTask::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/raw.rs", line: 84 }, { fn: "tokio::runtime::task::LocalNotified<S>::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/mod.rs", line: 376 }, { fn: "tokio::runtime::thread_pool::worker::Context::run_task::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 431 }, { fn: "tokio::coop::with_budget::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/coop.rs", line: 102 }, { fn: "std::thread::local::LocalKey<T>::try_with", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/thread/local.rs", line: 445 }, { fn: "std::thread::local::LocalKey<T>::with", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/thread/local.rs", line: 421 }, { fn: "tokio::coop::with_budget", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/coop.rs", line: 95 }, { fn: "tokio::coop::budget", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/coop.rs", line: 72 }, { fn: "tokio::runtime::thread_pool::worker::Context::run_task", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 430 }, { fn: "tokio::runtime::thread_pool::worker::Context::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 397 }, { fn: "tokio::runtime::thread_pool::worker::run::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 382 }, { fn: "tokio::macros::scoped_tls::ScopedKey<T>::set", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/macros/scoped_tls.rs", line: 61 }, { fn: "tokio::runtime::thread_pool::worker::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 379 }, { fn: "tokio::runtime::thread_pool::worker::Launch::launch::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 358 }, { fn: "<tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/blocking/task.rs", line: 42 }, { fn: "tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/core.rs", line: 165 }, { fn: "tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/loom/std/unsafe_cell.rs", line: 14 }, { fn: "tokio::runtime::task::core::CoreStage<T>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/core.rs", line: 155 }, { fn: "tokio::runtime::task::harness::poll_future::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 470 }, { fn: "<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panic/unwind_safe.rs", line: 271 }, { fn: "std::panicking::try::do_call", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 492 }, { fn: "__rust_try" }, { fn: "std::panicking::try", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 456 }, { fn: "std::panic::catch_unwind", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panic.rs", line: 137 }, { fn: "tokio::runtime::task::harness::poll_future", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 458 }, { fn: "tokio::runtime::task::harness::Harness<T,S>::poll_inner", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 104 }, { fn: "tokio::runtime::task::harness::Harness<T,S>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 57 }, { fn: "tokio::runtime::task::raw::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/raw.rs", line: 144 }, { fn: "tokio::runtime::task::raw::RawTask::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/raw.rs", line: 84 }, { fn: "tokio::runtime::task::UnownedTask<S>::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/mod.rs", line: 413 }, { fn: "tokio::runtime::blocking::pool::Task::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/blocking/pool.rs", line: 91 }, { fn: "tokio::runtime::blocking::pool::Inner::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/blocking/pool.rs", line: 325 }, { fn: "tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/blocking/pool.rs", line: 300 }, { fn: "std::sys_common::backtrace::__rust_begin_short_backtrace", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys_common/backtrace.rs", line: 122 }, { fn: "std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/thread/mod.rs", line: 501 }, { fn: "<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panic/unwind_safe.rs", line: 271 }, { fn: "std::panicking::try::do_call", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 492 }, { fn: "__rust_try" }, { fn: "std::panicking::try", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 456 }, { fn: "std::panic::catch_unwind", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panic.rs", line: 137 }, { fn: "std::thread::Builder::spawn_unchecked_::{{closure}}", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/thread/mod.rs", line: 500 }, { fn: "core::ops::function::FnOnce::call_once{{vtable.shim}}", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/ops/function.rs", line: 248 }, { fn: "<alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/alloc/src/boxed.rs", line: 1872 }, { fn: "<alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/alloc/src/boxed.rs", line: 1872 }, { fn: "std::sys::unix::thread::Thread::new::thread_start", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys/unix/thread.rs", line: 108 }, { fn: "start_thread", file: "/build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c", line: 477 }, { fn: "clone", file: "/build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S", line: 95 }] panic.file="/ubuntu/xx/.cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs" panic.line=454 panic.column=48

panic info:

panicked at 'called `Result::unwrap()` on an `Err` value: Error(Error { input: [9], code: Tag })'
TCeason commented 2 years ago

Now we can sure: the pacic is here : opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs panic.file=".cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs" panic.line=454 panic.column=48

    async fn run(mut self) -> Result<(), B::Error> {
        use crate::commands::Command;

        let mut stmts: HashMap<u32, _> = HashMap::new();
        while let Some((seq, packet)) = self.reader.next_async().await? {
            self.writer.set_seq(seq + 1);
-->            let cmd = commands::parse(&packet).unwrap().1;

Error info:

Error(Error { input: [9], code: Tag })', /ubuntu/xx/.cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs:454:48 backtrace=Backtrace [{ fn: "common_tracing::panic_hook::log_panic", file: "./common/tracing/src/panic_hook.rs", line: 31 }, { fn: "common_tracing::panic_hook::set_panic_hook::{{closure}}", file: "./common/tracing/src/panic_hook.rs", line: 26 }, { fn: "std::panicking::rust_panic_with_hook", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 702 }, { fn: "std::panicking::begin_panic_handler::{{closure}}", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 588 }, { fn: "std::sys_common::backtrace::__rust_end_short_backtrace", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys_common/backtrace.rs", line: 138 }, { fn: "rust_begin_unwind", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 584 }, { fn: "core::panicking::panic_fmt", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panicking.rs", line: 142 }, { fn: "core::result::unwrap_failed", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/result.rs", line: 1785 }, { fn: "core::result::Result<T,E>::unwrap", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/result.rs", line: 1078 }, { fn: "opensrv_mysql::AsyncMysqlIntermediary<B,S>::run::{{closure}}", file: "/ubuntu/xx/.cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs", line: 454 }, { fn: "<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/future/mod.rs", line: 91 }, { fn: "opensrv_mysql::AsyncMysqlIntermediary<B,S>::run_with_options::{{closure}}", file: "/ubuntu/xx/.cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs", line: 250 }, { fn: "<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/future/mod.rs", line: 91 }, { fn: "databend_query::servers::mysql::mysql_session::MySQLConnection::run_on_stream::{{closure}}::{{closure}}", file: "./query/src/servers/mysql/mysql_session.rs", line: 52 }, { fn: "<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/future/mod.rs", line: 91 }, { fn: "tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/core.rs", line: 165 }, { fn: "tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/loom/std/unsafe_cell.rs", line: 14 }, { fn: "tokio::runtime::task::core::CoreStage<T>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/core.rs", line: 155 }, { fn: "tokio::runtime::task::harness::poll_future::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 470 }, { fn: "<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panic/unwind_safe.rs", line: 271 }, { fn: "std::panicking::try::do_call", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 492 }, { fn: "__rust_try" }, { fn: "std::panicking::try", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 456 }, { fn: "std::panic::catch_unwind", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panic.rs", line: 137 }, { fn: "tokio::runtime::task::harness::poll_future", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 458 }, { fn: "tokio::runtime::task::harness::Harness<T,S>::poll_inner", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 104 }, { fn: "tokio::runtime::task::harness::Harness<T,S>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 57 }, { fn: "tokio::runtime::task::raw::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/raw.rs", line: 144 }, { fn: "tokio::runtime::task::raw::RawTask::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/raw.rs", line: 84 }, { fn: "tokio::runtime::task::LocalNotified<S>::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/mod.rs", line: 376 }, { fn: "tokio::runtime::thread_pool::worker::Context::run_task::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 431 }, { fn: "tokio::coop::with_budget::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/coop.rs", line: 102 }, { fn: "std::thread::local::LocalKey<T>::try_with", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/thread/local.rs", line: 445 }, { fn: "std::thread::local::LocalKey<T>::with", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/thread/local.rs", line: 421 }, { fn: "tokio::coop::with_budget", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/coop.rs", line: 95 }, { fn: "tokio::coop::budget", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/coop.rs", line: 72 }, { fn: "tokio::runtime::thread_pool::worker::Context::run_task", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 430 }, { fn: "tokio::runtime::thread_pool::worker::Context::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 397 }, { fn: "tokio::runtime::thread_pool::worker::run::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 382 }, { fn: "tokio::macros::scoped_tls::ScopedKey<T>::set", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/macros/scoped_tls.rs", line: 61 }, { fn: "tokio::runtime::thread_pool::worker::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 379 }, { fn: "tokio::runtime::thread_pool::worker::Launch::launch::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/thread_pool/worker.rs", line: 358 }, { fn: "<tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/blocking/task.rs", line: 42 }, { fn: "tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/core.rs", line: 165 }, { fn: "tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/loom/std/unsafe_cell.rs", line: 14 }, { fn: "tokio::runtime::task::core::CoreStage<T>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/core.rs", line: 155 }, { fn: "tokio::runtime::task::harness::poll_future::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 470 }, { fn: "<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panic/unwind_safe.rs", line: 271 }, { fn: "std::panicking::try::do_call", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 492 }, { fn: "__rust_try" }, { fn: "std::panicking::try", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 456 }, { fn: "std::panic::catch_unwind", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panic.rs", line: 137 }, { fn: "tokio::runtime::task::harness::poll_future", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 458 }, { fn: "tokio::runtime::task::harness::Harness<T,S>::poll_inner", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 104 }, { fn: "tokio::runtime::task::harness::Harness<T,S>::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/harness.rs", line: 57 }, { fn: "tokio::runtime::task::raw::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/raw.rs", line: 144 }, { fn: "tokio::runtime::task::raw::RawTask::poll", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/raw.rs", line: 84 }, { fn: "tokio::runtime::task::UnownedTask<S>::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/task/mod.rs", line: 413 }, { fn: "tokio::runtime::blocking::pool::Task::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/blocking/pool.rs", line: 91 }, { fn: "tokio::runtime::blocking::pool::Inner::run", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/blocking/pool.rs", line: 325 }, { fn: "tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}", file: "/ubuntu/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/runtime/blocking/pool.rs", line: 300 }, { fn: "std::sys_common::backtrace::__rust_begin_short_backtrace", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys_common/backtrace.rs", line: 122 }, { fn: "std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/thread/mod.rs", line: 501 }, { fn: "<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/panic/unwind_safe.rs", line: 271 }, { fn: "std::panicking::try::do_call", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 492 }, { fn: "__rust_try" }, { fn: "std::panicking::try", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panicking.rs", line: 456 }, { fn: "std::panic::catch_unwind", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/panic.rs", line: 137 }, { fn: "std::thread::Builder::spawn_unchecked_::{{closure}}", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/thread/mod.rs", line: 500 }, { fn: "core::ops::function::FnOnce::call_once{{vtable.shim}}", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/core/src/ops/function.rs", line: 248 }, { fn: "<alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/alloc/src/boxed.rs", line: 1872 }, { fn: "<alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/alloc/src/boxed.rs", line: 1872 }, { fn: "std::sys::unix::thread::Thread::new::thread_start", file: "/rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/library/std/src/sys/unix/thread.rs", line: 108 }, { fn: "start_thread", file: "/build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c", line: 477 }, { fn: "clone", file: "/build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S", line: 95 }] panic.file="/ubuntu/xx/.cargo/git/checkouts/opensrv-2d23bfb068524349/967477f/mysql/src/lib.rs" panic.line=454 panic.column=48

panic info:

panicked at 'called `Result::unwrap()` on an `Err` value: Error(Error { input: [9], code: Tag })'

Because of this, I think we should remove the unwrap() and handle the fact that commands::parse(&packet) may fail.

But I'm not sure how to deal with it. So help wanted.

TCeason commented 2 years ago

@PsiACE Do you have some suggestions?

TCeason commented 2 years ago
let res = commands::parse(&packet);
            match res {
                Ok(cmd) => {
                    match cmd.1 {
                        Command::Query(q) => {}
                        ...
                    }
                }
                Err(..) => {

                }
             }
PsiACE commented 2 years ago
let res = commands::parse(&packet);
            match res {
                Ok(cmd) => {
                    match cmd.1 {
                        Command::Query(q) => {}
                        ...
                    }
                }
                Err(..) => {

                }
             }

It looks like this will handle the error. I am not sure if this issue can be fixed.

TCeason commented 2 years ago
```rust
let res = commands::parse(&packet);
            match res {
                Ok(cmd) => {
                    match cmd.1 {
                        Command::Query(q) => {}
                        ...
                    }
                }
                Err(..) => {

                }
             }

It looks like this will handle the error. I am not sure if this issue can be fixed.

Yep absolutely agree. But how to deal with this err? Return Ok()?

BohuTANG commented 2 years ago

If we raised the error what will happen?

TCeason commented 2 years ago

If we raised the error what will happen?

if this raised err, run_with_options will also raised err.

pub fn run_on_stream(session: SessionRef, stream: TcpStream) -> Result<()> {
        let blocking_stream = Self::convert_stream(stream)?;
        MySQLConnection::attach_session(&session, &blocking_stream)?;

        let non_blocking_stream = TcpStream::from_std(blocking_stream)?;
        let query_executor =
            Runtime::with_worker_threads(1, Some("mysql-query-executor".to_string()))?;
        Thread::spawn(move || {
            let join_handle = query_executor.spawn(async move {
                let client_addr = non_blocking_stream.peer_addr().unwrap().to_string();
                let interactive_worker = InteractiveWorker::create(session, client_addr);
                let opts = IntermediaryOptions {
                    process_use_statement_on_query: true,
                };
                AsyncMysqlIntermediary::run_with_options(
                    interactive_worker,
                    non_blocking_stream,
                    &opts,
                )
                .await // error in here
            });
            let _ = futures::executor::block_on(join_handle);
        });
        Ok(())
    }

// will rasied err.
pub async fn run_with_options(
        shim: B,
        stream: S,
        opts: &IntermediaryOptions,
    ) -> Result<(), B::Error> {
    mi.run().await 
}

And I see in ClickHouse if use mysql client connects to ck server with 9004 port and executes status will return this result and is same with databend query.

default@mysqldb 22:58:01 [(none)]> status;
--------------
mysql  Ver 8.0.29-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))

Connection id:      1
Current database:   default
Current user:       default
SSL:            Not in use
Current pager:      less
Using outfile:      ''
Using delimiter:    ;
Server version:     22.5.1.2079-ClickHouse 
Protocol version:   10
Connection:     127.0.0.1 via TCP/IP
Server characterset:    0
Db     characterset:    0
Client characterset:    0
Conn.  characterset:    0
TCP port:       9004
Binary data as:     Hexadecimal
--------------

and in server.log, it log some error.

2022.06.10 23:01:05.527178 [ 105340 ] {} <Debug> DiskLocal: Reserving 1.00 MiB on disk `default`, having unreserved 78.20 GiB.
2022.06.10 23:01:05.633343 [ 105288 ] {} <Debug> MySQLHandler: Received command: 3. Connection id: 0.
2022.06.10 23:01:05.633565 [ 105288 ] {} <Debug> MYSQL-Session: da39842d-c627-43ab-8c52-aaf25e655d7c Creating query context from session context, user_id: 94309d50-4f52-5250-31bd-74fecac179db, parent context user: default
2022.06.10 23:01:05.634216 [ 105288 ] {mysql:0:b80f3386-c4c9-4d25-9302-451a9ca62937} <Debug> executeQuery: (from 127.0.0.1:45002) select DATABASE(), USER() limit 1
2022.06.10 23:01:05.635913 [ 105288 ] {mysql:0:b80f3386-c4c9-4d25-9302-451a9ca62937} <Information> executeQuery: Read 1 rows, 1.00 B in 0.001538819 sec., 649 rows/sec., 649.85 B/sec.
2022.06.10 23:01:05.636159 [ 105288 ] {mysql:0:b80f3386-c4c9-4d25-9302-451a9ca62937} <Debug> MemoryTracker: Peak memory usage (for query): 0.00 B.
2022.06.10 23:01:05.636336 [ 105288 ] {} <Debug> MySQLHandler: Received command: 3. Connection id: 0.
2022.06.10 23:01:05.636496 [ 105288 ] {} <Debug> MYSQL-Session: da39842d-c627-43ab-8c52-aaf25e655d7c Creating query context from session context, user_id: 94309d50-4f52-5250-31bd-74fecac179db, parent context user: default
2022.06.10 23:01:05.636984 [ 105288 ] {mysql:0:765a0da5-c2e7-4348-99cb-5ba410823f7b} <Debug> executeQuery: (from 127.0.0.1:45002) select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1
2022.06.10 23:01:05.638563 [ 105288 ] {mysql:0:765a0da5-c2e7-4348-99cb-5ba410823f7b} <Information> executeQuery: Read 1 rows, 1.00 B in 0.001480228 sec., 675 rows/sec., 675.57 B/sec.
2022.06.10 23:01:05.638619 [ 105288 ] {mysql:0:765a0da5-c2e7-4348-99cb-5ba410823f7b} <Debug> MemoryTracker: Peak memory usage (for query): 0.00 B.
2022.06.10 23:01:05.638652 [ 105288 ] {} <Debug> MySQLHandler: Received command: 9. Connection id: 0.
2022.06.10 23:01:05.638800 [ 105288 ] {} <Error> MySQLHandler: MySQLHandler: Cannot read packet: : Code: 48. DB::Exception: Command [ERRFMT] is not implemented. (NOT_IMPLEMENTED), Stack trace (when copying this message, always include the lines below):

0. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0xb4903fa in /usr/bin/clickhouse
1. DB::MySQLHandler::run() @ 0x16a7b6ec in /usr/bin/clickhouse
2. Poco::Net::TCPServerConnection::start() @ 0x1b0bbc2f in /usr/bin/clickhouse
3. Poco::Net::TCPServerDispatcher::run() @ 0x1b0be081 in /usr/bin/clickhouse
4. Poco::PooledThread::run() @ 0x1b284169 in /usr/bin/clickhouse
5. Poco::ThreadImpl::runnableEntry(void*) @ 0x1b2814c0 in /usr/bin/clickhouse
6. ? @ 0x7f1b3b5aa609 in ?
7. clone @ 0x7f1b3b4cf133 in ?
 (version 22.5.1.2079 (official build))
TCeason commented 2 years ago

ERRFMT:https://docs.pocoproject.org/current/Poco.html Poco::format(): an argument that does not match the format specifier no longer results in a BadCastException. The string [ERRFMT] is written to the result string instead.