databendlabs / databend

๐——๐—ฎ๐˜๐—ฎ, ๐—”๐—ป๐—ฎ๐—น๐˜†๐˜๐—ถ๐—ฐ๐˜€ & ๐—”๐—œ. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.87k stars 751 forks source link

bug: merge into matched update #16885

Open b41sh opened 1 day ago

b41sh commented 1 day ago

Search before asking

Version

v1.2.662

What's Wrong?

merge into panic

panicked at src/query/expression/src/block.rs:214:22:
index out of bounds: the len is 3 but the index is 3
   0: backtrace::backtrace::libunwind::trace
             at /home/b41sh/.cargo/git/checkouts/backtrace-rs-fb1f822361417489/72265be/src/backtrace/libunwind.rs:116:5
      backtrace::backtrace::trace_unsynchronized
             at /home/b41sh/.cargo/git/checkouts/backtrace-rs-fb1f822361417489/72265be/src/backtrace/mod.rs:66:5
   1: backtrace::backtrace::trace
             at /home/b41sh/.cargo/git/checkouts/backtrace-rs-fb1f822361417489/72265be/src/backtrace/mod.rs:53:14
   2: databend_common_tracing::panic_hook::captures_frames
             at /data2/b41sh/databend/src/common/tracing/src/panic_hook.rs:67:5
   3: databend_common_tracing::panic_hook::backtrace
             at /data2/b41sh/databend/src/common/tracing/src/panic_hook.rs:75:5
   4: databend_common_tracing::panic_hook::log_panic
             at /data2/b41sh/databend/src/common/tracing/src/panic_hook.rs:48:25
   5: databend_common_tracing::panic_hook::set_panic_hook::{{closure}}
             at /data2/b41sh/databend/src/common/tracing/src/panic_hook.rs:33:9
   6: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/alloc/src/boxed.rs:2078:9
      std::panicking::rust_panic_with_hook
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panicking.rs:804:13
   7: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panicking.rs:670:13
   8: std::sys::backtrace::__rust_end_short_backtrace
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/sys/backtrace.rs:171:18
   9: rust_begin_unwind
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panicking.rs:661:5
  10: core::panicking::panic_fmt
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/panicking.rs:74:14
  11: core::panicking::panic_bounds_check
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/panicking.rs:276:5
  12: <usize as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/slice/index.rs:292:10
  13: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/slice/index.rs:16:9
      <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/alloc/src/vec/mod.rs:2906:9
  14: databend_common_expression::block::DataBlock::get_by_offset
             at /data2/b41sh/databend/src/query/expression/src/block.rs:214:22
  15: databend_common_expression::evaluator::Evaluator::check_expr
             at /data2/b41sh/databend/src/query/expression/src/evaluator.rs:118:26
  16: databend_common_expression::evaluator::Evaluator::partial_run
             at /data2/b41sh/databend/src/query/expression/src/evaluator.rs:159:9
  17: databend_common_expression::evaluator::Evaluator::run
             at /data2/b41sh/databend/src/query/expression/src/evaluator.rs:134:9
  18: databend_common_storages_fuse::operations::merge_into::mutator::split_by_expr_mutator::SplitByExprMutator::split_by_expr
             at /data2/b41sh/databend/src/query/storages/fuse/src/operations/merge_into/mutator/split_by_expr_mutator.rs:47:30
  19: <databend_common_storages_fuse::operations::merge_into::processors::processor_merge_into_not_matched::MergeIntoNotMatchedProcessor as databend_common_pipeline_core::processors::processor::Processor>::process
             at /data2/b41sh/databend/src/query/storages/fuse/src/operations/merge_into/processors/processor_merge_into_not_matched.rs:171:21
  20: databend_common_pipeline_core::processors::processor::ProcessorPtr::process
             at /data2/b41sh/databend/src/query/pipeline/core/src/processors/processor.rs:169:9
  21: databend_query::pipelines::executor::executor_worker_context::ExecutorWorkerContext::execute_sync_task
             at /data2/b41sh/databend/src/query/service/src/pipelines/executor/executor_worker_context.rs:169:9
  22: databend_query::pipelines::executor::executor_worker_context::ExecutorWorkerContext::execute_task
             at /data2/b41sh/databend/src/query/service/src/pipelines/executor/executor_worker_context.rs:132:52
  23: databend_query::pipelines::executor::query_pipeline_executor::QueryPipelineExecutor::execute_single_thread
             at /data2/b41sh/databend/src/query/service/src/pipelines/executor/query_pipeline_executor.rs:406:35
  24: databend_query::pipelines::executor::query_pipeline_executor::QueryPipelineExecutor::execute_threads::{{closure}}::{{closure}}
             at /data2/b41sh/databend/src/query/service/src/pipelines/executor/query_pipeline_executor.rs:378:50
  25: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/panic/unwind_safe.rs:272:9
  26: std::panicking::try::do_call
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panicking.rs:553:40
  27: __rust_try
  28: std::panicking::try
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panicking.rs:517:19
      std::panic::catch_unwind
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panic.rs:350:14
  29: databend_common_base::runtime::catch_unwind::catch_unwind
             at /data2/b41sh/databend/src/common/base/src/runtime/catch_unwind.rs:47:11
  30: databend_query::pipelines::executor::query_pipeline_executor::QueryPipelineExecutor::execute_threads::{{closure}}
             at /data2/b41sh/databend/src/query/service/src/pipelines/executor/query_pipeline_executor.rs:378:34
  31: databend_common_base::runtime::runtime_tracker::ThreadTracker::tracking_function::{{closure}}::{{closure}}
             at /data2/b41sh/databend/src/common/base/src/runtime/runtime_tracker.rs:208:17
  32: databend_common_base::runtime::thread::Thread::named_spawn::{{closure}}
             at /data2/b41sh/databend/src/common/base/src/runtime/thread.rs:78:21
  33: std::sys::backtrace::__rust_begin_short_backtrace
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/sys/backtrace.rs:155:18
  34: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/thread/mod.rs:542:17
  35: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/panic/unwind_safe.rs:272:9
  36: std::panicking::try::do_call
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panicking.rs:553:40
  37: __rust_try
  38: std::panicking::try
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panicking.rs:517:19
      std::panic::catch_unwind
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panic.rs:350:14
      std::thread::Builder::spawn_unchecked_::{{closure}}
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/thread/mod.rs:541:30
  39: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/ops/function.rs:250:5
  40: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/alloc/src/boxed.rs:2064:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/alloc/src/boxed.rs:2064:9
      std::sys::pal::unix::thread::Thread::new::thread_start
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/sys/pal/unix/thread.rs:108:17
  41: <unknown>
  42: <unknown>

How to Reproduce?

root@0.0.0.0:48000/default> create or replace table t40(c0 bool, c1 TINYINT, c2 SMALLINT, c3 int);

processed in (0.084 sec)

root@0.0.0.0:48000/default> MERGE INTO t40 USING (
    SELECT NULL AS cqErrg0 FROM generate_series(to_timestamp(5964463314946), to_timestamp(5964463324946))) AS tQyf13(cqErrg0)
    ON c3 <= 1211599673896589479
    WHEN NOT MATCHED AND t40.$1
        THEN INSERT (c0, c1) VALUES(FALSE, 10)
    WHEN MATCHED AND c0
        THEN UPDATE SET c3 = c3;

error: APIError: ResponseError with 1104: index out of bounds: the len is 3 but the index is 3

Are you willing to submit PR?