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

panic: index out of bounds: the len is 2 but the index is 2 with constant column, GROUP BY #8713

Closed
1 task
philip-stoev opened this issue Oct 18, 2021 · 0 comments · Fixed by #8726
Closed
1 task
Assignees
Labels
A-optimization Area: query optimization and transformation C-bug Category: something is broken
Projects

Comments

@philip-stoev
Copy link
Contributor

philip-stoev commented Oct 18, 2021

What version of Materialize are you using?

v0.9.9-dev (3b1916362)
  • Materialize Cloud

What was the issue?

Certain queries cause the panic below. It appears that the common pattern is 1) constant item in the SELECT list; 2) GROUP BY over some other columns

2021-10-18T13:41:34.270097Z ERROR panic: index out of bounds: the len is 2 but the index is 2
thread: coordinator
location: src/transform/src/map_lifting.rs:160:46
version: 0.9.9-dev (3b1916362e064d977ee871319437d373fda5837a)
backtrace:
   0: materialized::handle_panic
             at src/materialized/src/bin/materialized/main.rs:802:21
   1: core::ops::function::Fn::call
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:70:5
   2: std::panicking::rust_panic_with_hook
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:626:17
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:519:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:141:18
   5: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   6: core::panicking::panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
   7: core::panicking::panic_bounds_check
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:69:5
   8: <usize as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/slice/index.rs:184:10
      core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/slice/index.rs:15:9
      <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/mod.rs:2428:9
      transform::map_lifting::LiteralLifting::action::{{closure}}
             at src/transform/src/map_lifting.rs:160:46
      core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:269:13
      <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::find
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/slice/iter/macros.rs:251:24
      <core::iter::adapters::filter::Filter<I,P> as core::iter::traits::iterator::Iterator>::next
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/iter/adapters/filter.rs:56:9
      <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/iter/adapters/map.rs:101:9
      alloc::vec::Vec<T,A>::extend_desugared
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/mod.rs:2546:35
      <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/spec_extend.rs:18:9
      <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/spec_from_iter_nested.rs:37:9
      <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/spec_from_iter.rs:33:9
   9: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/mod.rs:2449:9
      core::iter::traits::iterator::Iterator::collect
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/iter/traits/iterator.rs:1748:9
      transform::map_lifting::LiteralLifting::action
             at src/transform/src/map_lifting.rs:158:36
  10: <transform::map_lifting::LiteralLifting as transform::Transform>::transform
             at src/transform/src/map_lifting.rs:43:24
  11: <transform::Fixpoint as transform::Transform>::transform
             at src/transform/src/lib.rs:116:17
  12: transform::Optimizer::transform
             at src/transform/src/lib.rs:362:13
      transform::dataflow::optimize_dataflow_relations
             at src/transform/src/dataflow.rs:166:9
      transform::dataflow::optimize_dataflow
             at src/transform/src/dataflow.rs:36:5
  13: coord::coord::Coordinator::finalize_dataflow
             at src/coord/src/coord.rs:3947:9
  14: coord::coord::Coordinator::sequence_peek
             at src/coord/src/coord.rs:2888:29
  15: coord::coord::Coordinator::sequence_plan
             at src/coord/src/coord.rs:1755:25
  16: coord::coord::Coordinator::message_statement_ready::{{closure}}
             at src/coord/src/coord.rs:807:25
      <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/future/mod.rs:80:19
      coord::coord::Coordinator::serve::{{closure}}
             at src/coord/src/coord.rs:589:51
      <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/future/mod.rs:80:19
  17: tokio::park::thread::CachedParkThread::block_on::{{closure}}
             at /home/pstoev/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/park/thread.rs:263:54
      tokio::coop::with_budget::{{closure}}
             at /home/pstoev/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/coop.rs:106:9
      std::thread::local::LocalKey<T>::try_with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:400:16
      std::thread::local::LocalKey<T>::with
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/local.rs:376:9
      tokio::coop::with_budget
             at /home/pstoev/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/coop.rs:99:5
      tokio::coop::budget
             at /home/pstoev/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/coop.rs:76:5
      tokio::park::thread::CachedParkThread::block_on
             at /home/pstoev/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/park/thread.rs:263:31
  18: tokio::runtime::enter::Enter::block_on
             at /home/pstoev/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/runtime/enter.rs:151:13
      tokio::runtime::handle::Handle::block_on
             at /home/pstoev/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/runtime/handle.rs:311:9
  19: coord::coord::serve::{{closure}}::{{closure}}
             at src/coord/src/coord.rs:4249:13
      std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:125:18
  20: std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/mod.rs:481:17
      <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panic.rs:347:9
      std::panicking::try::do_call
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:401:40
      std::panicking::try
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:365:19
      std::panic::catch_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panic.rs:434:14
      std::thread::Builder::spawn_unchecked::{{closure}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/mod.rs:480:30
      core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:227:5
  21: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/boxed.rs:1575:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/boxed.rs:1575:9
      std::sys::unix::thread::Thread::new::thread_start
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys/unix/thread.rs:71:17
  22: start_thread
             at /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477:8
  23: clone

Is the issue reproducible? If so, please provide reproduction instructions.

CREATE VIEW t1 (f1, f2) AS (VALUES (NULL, 0), (1, 1), (1, 1), (2, 2),  (2, 2), (3, 3), (4, 4), (5, 5), (6, 6),(7, 7),(8, 8));

CREATE VIEW t2 (f1, f2) AS (VALUES (NULL, 0),(NULL, 0),(1, 1),(2, 2), (2, 2),(4, 4), (5, 5),(6, 6),(7, 7),(8, 8));

SELECT  FROM (  SELECT  FROM t2 a1  RIGHT JOIN t1 a2  ON a1 .f1  = a2 .f2  ) group by true; 

SELECT  TRUE  , a1  , a2  FROM t2 a1  LEFT  JOIN (  SELECT  8 f1  , f1 f2  FROM t2  ) a2  ON a2 .f2  + a2 .f1  <  9  GROUP  BY  2  ,  3;
@philip-stoev philip-stoev added C-bug Category: something is broken A-optimization Area: query optimization and transformation labels Oct 18, 2021
@philip-stoev philip-stoev added this to Needs Triage in Compute via automation Oct 18, 2021
@asenac asenac assigned asenac and unassigned asenac Oct 19, 2021
@umanwizard umanwizard self-assigned this Oct 19, 2021
Compute automation moved this from Needs Triage to Done Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-optimization Area: query optimization and transformation C-bug Category: something is broken
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants