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

UDF panics if the function signature was modified discreetly. #10828

Closed
Tracked by #9002 ...
xxchan opened this issue Jul 7, 2023 · 3 comments · Fixed by #12202
Closed
Tracked by #9002 ...

UDF panics if the function signature was modified discreetly. #10828

xxchan opened this issue Jul 7, 2023 · 3 comments · Fixed by #12202
Assignees
Labels
type/bug Something isn't working
Milestone

Comments

@xxchan
Copy link
Member

xxchan commented Jul 7, 2023

Describe the bug

There's only check in frontend, but not expr, so we can restart the function server and change function signature.

@udf(input_types=["VARCHAR"], result_type="VARCHAR")
def foo(x) -> int:
    return "42"

Then create function

dev=> create function bar(varchar) returns varchar as 'foo' using link 'http://localhost:8815';
CREATE_FUNCTION
dev=> select bar('1');
 bar 
-----
 42
(1 row)

Then change code and restart server

@udf(input_types=["VARCHAR"], result_type="INT")
def foo(x) -> int:
    return 42

Then boom 💥

dev=> select bar('1');
ERROR:  Panicked when processing: internal error: entered unreachable code

Error message/log

thread 'risingwave-main' panicked at 'internal error: entered unreachable code', src/common/src/types/to_text.rs:107:1
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/panicking.rs:117:5
   3: <i32 as risingwave_common::types::to_text::ToText>::write_with_type
             at ./src/common/src/types/to_text.rs:94:30
   4: <risingwave_common::types::ScalarRefImpl as risingwave_common::types::to_text::ToText>::write_with_type
             at ./src/common/src/types/to_text.rs:207:58
   5: risingwave_common::types::to_text::ToText::to_text_with_type
             at ./src/common/src/types/to_text.rs:34:9
   6: risingwave_common::types::ScalarRefImpl::text_format
             at ./src/common/src/types/mod.rs:1055:9
   7: risingwave_frontend::handler::util::pg_value_format
             at ./src/frontend/src/handler/util.rs:126:20
   8: risingwave_frontend::handler::util::to_pg_rows::{{closure}}::{{closure}}
             at ./src/frontend/src/handler/util.rs:165:40
   9: core::iter::adapters::map::map_try_fold::{{closure}}
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/map.rs:91:28
  10: core::iter::traits::iterator::Iterator::try_fold
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/traits/iterator.rs:2303:21
  11: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/map.rs:117:9
  12: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::try_fold
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/mod.rs:195:9
  13: core::iter::traits::iterator::Iterator::try_for_each
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/traits/iterator.rs:2365:9
  14: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/mod.rs:178:14
  15: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/alloc/src/vec/spec_from_iter_nested.rs:26:32
  16: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/alloc/src/vec/spec_from_iter.rs:33:9
  17: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/alloc/src/vec/mod.rs:2711:9
  18: core::iter::traits::iterator::Iterator::collect
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/traits/iterator.rs:1895:9
  19: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter::{{closure}}
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/result.rs:1932:51
  20: core::iter::adapters::try_process
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/mod.rs:164:17
  21: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/result.rs:1932:9
  22: core::iter::traits::iterator::Iterator::collect
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/traits/iterator.rs:1895:9
  23: itertools::Itertools::try_collect
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.10.5/src/lib.rs:2014:9
  24: risingwave_frontend::handler::util::to_pg_rows::{{closure}}
             at ./src/frontend/src/handler/util.rs:160:23
  25: core::iter::adapters::map::map_try_fold::{{closure}}
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/map.rs:91:28
  26: core::iter::traits::iterator::Iterator::try_fold
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/traits/iterator.rs:2303:21
  27: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/map.rs:117:9
  28: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::try_fold
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/mod.rs:195:9
  29: core::iter::traits::iterator::Iterator::try_for_each
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/traits/iterator.rs:2365:9
  30: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/mod.rs:178:14
  31: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/alloc/src/vec/spec_from_iter_nested.rs:26:32
  32: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/alloc/src/vec/spec_from_iter.rs:33:9
  33: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/alloc/src/vec/mod.rs:2711:9
  34: core::iter::traits::iterator::Iterator::collect
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/traits/iterator.rs:1895:9
  35: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter::{{closure}}
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/result.rs:1932:51
  36: core::iter::adapters::try_process
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/adapters/mod.rs:164:17
  37: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/result.rs:1932:9
  38: core::iter::traits::iterator::Iterator::collect
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/iter/traits/iterator.rs:1895:9
  39: itertools::Itertools::try_collect
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.10.5/src/lib.rs:2014:9
  40: risingwave_frontend::handler::util::to_pg_rows
             at ./src/frontend/src/handler/util.rs:155:5
  41: <risingwave_frontend::handler::util::DataChunkToRowSetAdapter<VS> as futures_core::stream::Stream>::poll_next
             at ./src/frontend/src/handler/util.rs:101:25
  42: futures_util::stream::stream::StreamExt::poll_next_unpin
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/mod.rs:1632:9
  43: <risingwave_frontend::handler::PgResponseStream as futures_core::stream::Stream>::poll_next
             at ./src/frontend/src/handler/mod.rs:92:52
  44: futures_util::stream::stream::StreamExt::poll_next_unpin
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/mod.rs:1632:9
  45: <futures_util::stream::stream::next::Next<St> as core::future::future::Future>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/next.rs:32:9
  46: pgwire::pg_protocol::PgProtocol<S,SM>::inner_process_query_msg_one_stmt::{{closure}}
             at ./src/utils/pgwire/src/pg_protocol.rs:444:66
  47: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-0.1.37/src/instrument.rs:272:9
  48: pgwire::pg_protocol::PgProtocol<S,SM>::inner_process_query_msg::{{closure}}
             at ./src/utils/pgwire/src/pg_protocol.rs:401:18
  49: pgwire::pg_protocol::PgProtocol<S,SM>::process_query_msg::{{closure}}
             at ./src/utils/pgwire/src/pg_protocol.rs:365:65
  50: pgwire::pg_protocol::PgProtocol<S,SM>::do_process_inner::{{closure}}
             at ./src/utils/pgwire/src/pg_protocol.rs:244:88
  51: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::future::future::Future>::poll
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/panic/unwind_safe.rs:296:9
  52: <futures_util::future::future::catch_unwind::CatchUnwind<Fut> as core::future::future::Future>::poll::{{closure}}
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/future/catch_unwind.rs:36:42
  53: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/panic/unwind_safe.rs:271:9
  54: std::panicking::try::do_call
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/std/src/panicking.rs:500:40
  55: ___rust_try
  56: std::panicking::try
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/std/src/panicking.rs:464:19
  57: std::panic::catch_unwind
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/std/src/panic.rs:142:14
  58: <futures_util::future::future::catch_unwind::CatchUnwind<Fut> as core::future::future::Future>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/future/catch_unwind.rs:36:9
  59: <tokio::task::task_local::TaskLocalFuture<T,F> as core::future::future::Future>::poll::{{closure}}
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/task/task_local.rs:348:35
  60: tokio::task::task_local::LocalKey<T>::scope_inner
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/task/task_local.rs:233:19
  61: <tokio::task::task_local::TaskLocalFuture<T,F> as core::future::future::Future>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/task/task_local.rs:345:13
  62: pgwire::pg_protocol::PgProtocol<S,SM>::do_process::{{closure}}
             at ./src/utils/pgwire/src/pg_protocol.rs:169:14
  63: pgwire::pg_protocol::PgProtocol<S,SM>::process::{{closure}}
             at ./src/utils/pgwire/src/pg_protocol.rs:163:30
  64: pgwire::pg_server::handle_connection::{{closure}}::{{closure}}
             at ./src/utils/pgwire/src/pg_server.rs:173:45
  65: pgwire::pg_server::handle_connection::{{closure}}
             at ./src/utils/pgwire/src/pg_server.rs:158:1
  66: <F as futures_core::future::TryFuture>::try_poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-core-0.3.28/src/future.rs:82:9
  67: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/try_future/into_future.rs:34:9
  68: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/future/map.rs:55:37
  69: <futures_util::future::future::Inspect<Fut,F> as core::future::future::Future>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/lib.rs:91:13
  70: <futures_util::future::try_future::InspectErr<Fut,F> as core::future::future::Future>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/lib.rs:91:13
  71: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/future/future.rs:125:9
  72: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-0.1.37/src/instrument.rs:272:9
  73: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/task/core.rs:223:17
  74: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/loom/std/unsafe_cell.rs:14:9
  75: tokio::runtime::task::core::Core<T,S>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/task/core.rs:212:13
  76: tokio::runtime::task::harness::poll_future::{{closure}}
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/task/harness.rs:476:19
  77: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/panic/unwind_safe.rs:271:9
  78: std::panicking::try::do_call
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/std/src/panicking.rs:500:40
  79: ___rust_try
  80: std::panicking::try
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/std/src/panicking.rs:464:19
  81: std::panic::catch_unwind
             at /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/std/src/panic.rs:142:14
  82: tokio::runtime::task::harness::poll_future
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/task/harness.rs:464:18
  83: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/task/harness.rs:198:27
  84: tokio::runtime::task::harness::Harness<T,S>::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/task/harness.rs:152:15
  85: tokio::runtime::task::raw::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/task/raw.rs:255:5
  86: tokio::runtime::task::raw::RawTask::poll
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/task/raw.rs:200:18
  87: tokio::runtime::task::LocalNotified<S>::run
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/task/mod.rs:394:9
  88: tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/scheduler/multi_thread/worker.rs:464:13
  89: tokio::runtime::coop::with_budget
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/coop.rs:107:5
  90: tokio::runtime::coop::budget
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/coop.rs:73:5
  91: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/scheduler/multi_thread/worker.rs:463:9
  92: tokio::runtime::scheduler::multi_thread::worker::Context::run
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/scheduler/multi_thread/worker.rs:426:24
  93: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}
             at /Users/xxchan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.28.0/src/runtime/scheduler/multi_thread/worker.rs:406:17

To Reproduce

No response

Expected behavior

No response

How did you deploy RisingWave?

No response

The version of RisingWave

No response

Additional context

#9002

@xxchan xxchan added the type/bug Something isn't working label Jul 7, 2023
@github-actions github-actions bot added this to the release-0.20 milestone Jul 7, 2023
@xxchan
Copy link
Member Author

xxchan commented Jul 7, 2023

It panics in risingwave_frontend::handler::util::to_pg_rows. This is scary 🥵

@TennyZhuang
Copy link
Contributor

Any updates? At least we shouldn't panic here.

@TennyZhuang TennyZhuang modified the milestones: release-1.2, release-1.3 Sep 11, 2023
@wangrunji0408
Copy link
Contributor

Sorry for missing that. Will be fixed soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants