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

bug: ExprError from Project displayed with verbose stacktrace in batch #12815

Closed
neverchanje opened this issue Oct 12, 2023 · 1 comment · Fixed by #13010
Closed

bug: ExprError from Project displayed with verbose stacktrace in batch #12815

neverchanje opened this issue Oct 12, 2023 · 1 comment · Fixed by #13010
Assignees
Labels
type/bug Something isn't working
Milestone

Comments

@neverchanje
Copy link
Contributor

neverchanje commented Oct 12, 2023

Describe the bug

When the interval is unrealistically large that exceeds DateTime's limit, it causes panic.

Error message/log

ERROR:  QueryError: Internal(Expr error: Numeric out of range: overflow

Stack backtrace:
   0: std::backtrace_rs::backtrace::libunwind::trace
             at /rustc/62ebe3a2b177d50ec664798d731b8a8d1a9120d1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/62ebe3a2b177d50ec664798d731b8a8d1a9120d1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2: std::backtrace::Backtrace::create
             at /rustc/62ebe3a2b177d50ec664798d731b8a8d1a9120d1/library/std/src/backtrace.rs:331:13
   3: anyhow::kind::Adhoc::new
             at /Users/wutao/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.75/src/kind.rs:71:36
   4: <risingwave_batch::error::BatchError as core::convert::From<risingwave_common::error::RwError>>::from
             at ./src/batch/src/error.rs:68:18
   5: risingwave_batch::task::task_execution::BatchTaskExecution<C>::run::{{closure}}
             at ./src/batch/src/task/task_execution.rs:633:46
   6: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
             at /Users/wutao/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-0.1.37/src/instrument.rs:272:9
   7: risingwave_batch::task::task_execution::BatchTaskExecution<C>::async_execute::{{closure}}::{{closure}}::{{closure}}::{{closure}}
             at ./src/batch/src/task/task_execution.rs:474:22
   8: core::ops::function::FnOnce::call_once
             at /rustc/62ebe3a2b177d50ec664798d731b8a8d1a9120d1/library/core/src/ops/function.rs:250:5
   9: tokio_metrics::task::instrument_poll
             at /Users/wutao/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-metrics-0.3.0/src/task.rs:2530:15
  10: <tokio_metrics::task::Instrumented<T> as core::future::future::Future>::poll
             at /Users/wutao/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-metrics-0.3.0/src/task.rs:2430:9
  11: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::future::future::Future>::poll
             at /rustc/62ebe3a2b177d50ec664798d731b8a8d1a9120d1/library/core/src/panic/unwind_safe.rs:296:9
  12: <futures_util::future::future::catch_unwind::CatchUnwind<Fut> as core::future::future::Future>::poll::{{closure}}
             at /Users/wutao/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/future/catch_unwind.rs:36:42
  13: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/62ebe3a2b177d50ec664798d731b8a8d1a9120d1/library/core/src/panic/unwind_safe.rs:271:9

To Reproduce

Steps to reproduce:

  1. Prepare the data:
CREATE TABLE timestamp_example (
  id bigint PRIMARY KEY,
  event_timestamp timestamptz
);

INSERT INTO timestamp_example (id, event_timestamp) VALUES (1, '2023-10-11 12:00:00');
select  event_timestamp + interval '1000000 years 0 months 0 days' from timestamp_example;                                                                                                                                                     

I aslo attempted to create a panic by creating a materialized view on the query, but it was captured and filled with an empty value.

Expected behavior

No panic. Here is postgres's behavior, which returns a normal error instead:

postgres=# select event_timestamp + interval '1000000 years' from timestamp_example;
ERROR:  timestamp out of range

How did you deploy RisingWave?

No response

The version of RisingWave

9ad7857

Additional context

No response

@neverchanje neverchanje added the type/bug Something isn't working label Oct 12, 2023
@github-actions github-actions bot added this to the release-1.4 milestone Oct 12, 2023
@xiangjinwu xiangjinwu changed the title bug: timestamptz + interval overflow causes panic bug: ExprError from Project displayed with verbose stacktrace in batch Oct 12, 2023
@xiangjinwu
Copy link
Contributor

There is no panic, but the batch engine displays the ExprError with a stacktrace, which looks like a panic.

Caused by #8437:

Some(Err(e)) => match self.shutdown_rx.message() {
ShutdownMsg::Init => {
// There is no message received from shutdown channel, which means it caused
// task failed.
error!("Batch task failed: {:?}", e);
error = Some(BatchError::from(e));
state = TaskStatus::Failed;
break;
}
ShutdownMsg::Abort(_) => {
error = Some(BatchError::from(e));
state = TaskStatus::Aborted;
break;
}

// A temp workaround
impl From<RwError> for BatchError {
fn from(s: RwError) -> Self {
Internal(anyhow!(format!("{}", s)))
}
}

The stacktrace is added by anyhow!. I have confirmed that by replacing BatchError::from(e) with BatchError::Abort(e.to_string()), it would display a shorter message:

ERROR:  QueryError: Aborted("Expr error: Numeric out of range")

@liurenjie1024 Could you help adjust the error transformation here? I am not sure what is the better alternative to "A temp workaround" in this context.

related: #11443

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.

3 participants