Skip to content
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

index out of bounds while executing range query #2769

Closed
evenyag opened this issue Nov 17, 2023 · 1 comment · Fixed by #2770
Closed

index out of bounds while executing range query #2769

evenyag opened this issue Nov 17, 2023 · 1 comment · Fixed by #2770
Assignees
Labels
C-bug Category Bugs

Comments

@evenyag
Copy link
Contributor

evenyag commented Nov 17, 2023

What type of bug is this?

Crash, Unexpected error

What subsystems are affected?

Standalone mode, Datanode

Minimal reproduce step

CREATE TABLE IF NOT EXISTS range_test (
status DOUBLE, 
v DOUBLE,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
TIME INDEX(ts));

INSERT INTO range_test values (1, 1, 1);
INSERT INTO range_test values (2,2,2);

SELECT ts, MIN(v) RANGE '3600s' from "range_test" ALIGN '3600s';

What did you expect to see?

+---------------------+------------------------------------+
| ts                  | MIN(f02.val) RANGE 3600s FILL NULL |
+---------------------+------------------------------------+
| 1970-01-01 09:00:00 |                                  1 |
+---------------------+------------------------------------+

What did you see instead?

ERROR 2013 (HY000): Lost connection to MySQL server during query

What operating system did you use?

Unrelated

Relevant log output and stack trace

2023-11-17T07:08:21.204256Z ERROR common_telemetry::panic_hook: panicked at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-row-47.0.0/src/lib.rs:863:31:
index out of bounds: the len is 1 but the index is 1 backtrace=   0: common_telemetry::panic_hook::set_panic_hook::{{closure}}
             at /home/../src/common/telemetry/src/panic_hook.rs:37:25
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/alloc/src/boxed.rs:2021:9
      std::panicking::rust_panic_with_hook
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panicking.rs:733:13
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panicking.rs:621:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/sys_common/backtrace.rs:170:18
   4: rust_begin_unwind
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panicking.rs:617:5
   5: core::panicking::panic_fmt
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/panicking.rs:67:14
   6: core::panicking::panic_bounds_check
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/panicking.rs:162:5
   7: <usize as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/slice/index.rs:261:10
      core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/slice/index.rs:18:9
      <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/alloc/src/vec/mod.rs:2675:9
      arrow_row::Rows::row
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-row-47.0.0/src/lib.rs:863:31
   8: query::range_select::plan::RangeSelectStream::update_range_context::{{closure}}::{{closure}}
             at /home/greptimedb/src/query/src/range_select/plan.rs:768:34
      std::collections::hash::map::Entry<K,V>::or_insert_with
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/collections/hash/map.rs:2558:43
      query::range_select::plan::RangeSelectStream::update_range_context::{{closure}}
             at /home/greptimedb/src/query/src/range_select/plan.rs:767:25
      core::iter::traits::iterator::Iterator::try_for_each::call::{{closure}}
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/iter/traits/iterator.rs:2362:26
      core::iter::traits::iterator::Iterator::try_fold
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/iter/traits/iterator.rs:2303:21
      core::iter::traits::iterator::Iterator::try_for_each
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/iter/traits/iterator.rs:2365:9
      query::range_select::plan::RangeSelectStream::update_range_context
             at /home/greptimedb/src/query/src/range_select/plan.rs:759:57
      <query::range_select::plan::RangeSelectStream as futures_core::stream::Stream>::poll_next
             at /home/greptimedb/src/query/src/range_select/plan.rs:898:45
   9: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-core-0.3.28/src/stream.rs:120:9
      <common_recordbatch::adapter::RecordBatchStreamAdapter as futures_core::stream::Stream>::poll_next
             at /home/greptimedb/src/common/recordbatch/src/adapter.rs:200:15
  10: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-core-0.3.28/src/stream.rs:120:9
      futures_util::stream::stream::StreamExt::poll_next_unpin
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/mod.rs:1632:9
      <futures_util::stream::stream::next::Next<St> as core::future::future::Future>::poll
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/next.rs:32:21
      servers::mysql::writer::MysqlResultWriter<W>::write_query_result::{{closure}}
             at /home/greptimedb/src/servers/src/mysql/writer.rs:139:75
  11: servers::mysql::writer::MysqlResultWriter<W>::try_write_one::{{closure}}
             at /home/greptimedb/src/servers/src/mysql/writer.rs:88:93
      servers::mysql::writer::write_output::{{closure}}
             at /home/greptimedb/src/servers/src/mysql/writer.rs:44:54
  12: <servers::mysql::handler::MysqlInstanceShim as opensrv_mysql::AsyncMysqlShim<W>>::on_query::{{closure}}
             at /home/greptimedb/src/servers/src/mysql/handler.rs:331:58
  13: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/future/future.rs:125:9
      opensrv_mysql::AsyncMysqlIntermediary<B,R,W>::run::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opensrv-mysql-0.4.1/src/lib.rs:626:38
  14: opensrv_mysql::tls::plain_run_with_options::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opensrv-mysql-0.4.1/src/tls.rs:57:14
      servers::mysql::server::MysqlServer::do_handle::{{closure}}
             at /home/greptimedb/src/servers/src/mysql/server.rs:203:68
  15: servers::mysql::server::MysqlServer::handle::{{closure}}::{{closure}}
             at /home/greptimedb/src/servers/src/mysql/server.rs:163:79
  16: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/core.rs:328:17
      tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/loom/std/unsafe_cell.rs:16:9
      tokio::runtime::task::core::Core<T,S>::poll
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/core.rs:317:13
  17: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/harness.rs:485:19
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/panic/unwind_safe.rs:271:9
      std::panicking::try::do_call
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panicking.rs:524:40
      std::panicking::try
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panicking.rs:488:19
      std::panic::catch_unwind
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panic.rs:142:14
      tokio::runtime::task::harness::poll_future
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/harness.rs:473:18
      tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/harness.rs:208:27
      tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/harness.rs:153:15
  18: tokio::runtime::task::raw::RawTask::poll
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/raw.rs:200:18
      tokio::runtime::task::LocalNotified<S>::run
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/mod.rs:408:9
      tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/scheduler/multi_thread/worker.rs:576:18
      tokio::runtime::coop::with_budget
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/coop.rs:107:5
      tokio::runtime::coop::budget
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/coop.rs:73:5
      tokio::runtime::scheduler::multi_thread::worker::Context::run_task
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/scheduler/multi_thread/worker.rs:575:9
  19: tokio::runtime::scheduler::multi_thread::worker::Context::run
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/scheduler/multi_thread/worker.rs:526:24
  20: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/scheduler/multi_thread/worker.rs:491:21
      tokio::runtime::context::scoped::Scoped<T>::set
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/context/scoped.rs:40:9
      tokio::runtime::context::set_scheduler::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/context.rs:176:26
      std::thread::local::LocalKey<T>::try_with
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/thread/local.rs:270:16
      std::thread::local::LocalKey<T>::with
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/thread/local.rs:246:9
      tokio::runtime::context::set_scheduler
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/context.rs:176:17
      tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/scheduler/multi_thread/worker.rs:486:9
      tokio::runtime::context::runtime::enter_runtime
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/context/runtime.rs:65:16
  21: tokio::runtime::scheduler::multi_thread::worker::run
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/scheduler/multi_thread/worker.rs:478:5
  22: tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/scheduler/multi_thread/worker.rs:447:45
      <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/blocking/task.rs:42:21
      tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/core.rs:328:17
      tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/loom/std/unsafe_cell.rs:16:9
      tokio::runtime::task::core::Core<T,S>::poll
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/core.rs:317:13
  23: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/harness.rs:485:19
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/panic/unwind_safe.rs:271:9
      std::panicking::try::do_call
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panicking.rs:524:40
      std::panicking::try
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panicking.rs:488:19
      std::panic::catch_unwind
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panic.rs:142:14
      tokio::runtime::task::harness::poll_future
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/harness.rs:473:18
      tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/harness.rs:208:27
      tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/harness.rs:153:15
  24: tokio::runtime::task::raw::RawTask::poll
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/raw.rs:200:18
      tokio::runtime::task::UnownedTask<S>::run
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/task/mod.rs:445:9
      tokio::runtime::blocking::pool::Task::run
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/blocking/pool.rs:159:9
      tokio::runtime::blocking::pool::Inner::run
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/blocking/pool.rs:513:17
  25: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/runtime/blocking/pool.rs:471:13
      std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/sys_common/backtrace.rs:154:18
  26: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/thread/mod.rs:529:17
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/panic/unwind_safe.rs:271:9
      std::panicking::try::do_call
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panicking.rs:524:40
      std::panicking::try
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panicking.rs:488:19
      std::panic::catch_unwind
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/panic.rs:142:14
      std::thread::Builder::spawn_unchecked_::{{closure}}
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/thread/mod.rs:528:30
      core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/core/src/ops/function.rs:250:5
  27: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/alloc/src/boxed.rs:2007:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/alloc/src/boxed.rs:2007:9
      std::sys::unix::thread::Thread::new::thread_start
             at /rustc/f3623871cfa0763c95ebd6ceafaa6dc2e44ca68f/library/std/src/sys/unix/thread.rs:108:17
  28: start_thread
             at ./nptl/pthread_create.c:442:8
  29: clone3
             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
 panic.file="/home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-row-47.0.0/src/lib.rs" panic.line=863 panic.column=31
thread 'mysql-io-handlers' panicked at /home/greptimedb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-row-47.0.0/src/lib.rs:863:31:
index out of bounds: the len is 1 but the index is 1
@Taylor-lagrange
Copy link
Collaborator

Some check is added, this should solve the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category Bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants