risingwave_frontend/scheduler/
error.rs

1// Copyright 2022 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use risingwave_batch::error::BatchError;
16use risingwave_common::session_config::QueryMode;
17use risingwave_connector::error::ConnectorError;
18use risingwave_rpc_client::error::RpcError;
19use thiserror::Error;
20
21use crate::error::{ErrorCode, RwError};
22use crate::scheduler::plan_fragmenter::QueryId;
23
24#[derive(Error, Debug)]
25pub enum SchedulerError {
26    #[error("Pin snapshot error: {0} fails to get epoch {1}")]
27    PinSnapshot(QueryId, u64),
28
29    #[error(transparent)]
30    RpcError(
31        #[from]
32        #[backtrace]
33        RpcError,
34    ),
35
36    #[error("{0}")]
37    TaskExecutionError(String),
38
39    #[error("Task got killed because compute node running out of memory")]
40    TaskRunningOutOfMemory,
41
42    /// Used when receive cancel request for some reason, such as user cancel or timeout.
43    #[error("Query cancelled: {0}")]
44    QueryCancelled(String),
45
46    #[error(
47        "Reject query: the {0} query number reaches the limit: {1}. Use `SHOW PROCESSLIST` to check for hanging queries and cancel them if needed."
48    )]
49    QueryReachLimit(QueryMode, u64),
50
51    #[error(transparent)]
52    BatchError(
53        #[from]
54        #[backtrace]
55        BatchError,
56    ),
57
58    #[error(transparent)]
59    Connector(
60        #[from]
61        #[backtrace]
62        ConnectorError,
63    ),
64
65    #[error(transparent)]
66    Internal(
67        #[from]
68        #[backtrace]
69        anyhow::Error,
70    ),
71}
72
73impl From<SchedulerError> for RwError {
74    fn from(s: SchedulerError) -> Self {
75        ErrorCode::SchedulerError(Box::new(s)).into()
76    }
77}
78
79impl From<RwError> for SchedulerError {
80    fn from(e: RwError) -> Self {
81        Self::Internal(e.into())
82    }
83}